function mgm_patch_get_users($start, $limit) { global $wpdb; $qry = 'SELECT ID from ' . $wpdb->users . ' WHERE ID <> 1 ORDER BY ID LIMIT ' . $start . ',' . $limit; $uids = $wpdb->get_col($qry); if (!count($uids)) { return false; } foreach ($uids as $user_id) { mgm_remove_excess_user_roles($user_id, true); $member = mgm_get_member($user_id); $pack = mgm_get_option('subscription_packs')->get_pack($member->pack_id); if (!empty($pack['membership_type']) && $pack['membership_type'] != $member->membership_type && $member->status == MGM_STATUS_ACTIVE) { $member->membership_type = $pack['membership_type']; // update_user_option($user_id, 'mgm_member', $member, true); $member->save(); } } return true; }
<?php // reconfigure auth class $mgm_auth = new mgm_auth(); // get auth cached $mgm_auth_cached = mgm_get_option('auth'); // product_info if (!isset($mgm_auth_cached->product_info) || empty($mgm_auth_cached->product_info)) { $mgm_auth_cached->product_info = $mgm_auth->product_info; } // cache_timeout if (!isset($mgm_auth_cached->cache_timeout) || empty($mgm_auth_cached->cache_timeout)) { $mgm_auth_cached->cache_timeout = $mgm_auth->cache_timeout; } // save update_option('mgm_auth', $mgm_auth_cached); // end upgrade 4.3
<?php /** * Objects merge/update */ // saved object $member_custom_fields = mgm_get_option('member_custom_fields'); // new $custom_fields = array(); // loop foreach ($member_custom_fields->custom_fields as $custom_field) { // check display if (!isset($custom_field['display'])) { // loop foreach (array('on_register', 'on_profile', 'on_payment', 'on_public_profile', 'on_upgrade', 'on_extend') as $property) { // skip for coupon if ($custom_field['name'] != 'coupon' && in_array($property, array('on_upgrade', 'on_extend'))) { continue; } // if set if (isset($custom_field[$property])) { $property_value = $custom_field[$property]; } else { $property_value = false; } // set $custom_field['display'][$property] = $property_value; } } // check attributes if (!isset($custom_field['attributes'])) {
<?php /** * Objects merge/update */ // saved object $system_obj_cached = mgm_get_option('system'); // set new vars if (!isset($system_obj_cached->setting['thumbnail_image_width'])) { $system_obj_cached->setting['thumbnail_image_width'] = '32'; } if (!isset($system_obj_cached->setting['thumbnail_image_height'])) { $system_obj_cached->setting['thumbnail_image_height'] = '32'; } if (!isset($system_obj_cached->setting['medium_image_width'])) { $system_obj_cached->setting['medium_image_width'] = '120'; } if (!isset($system_obj_cached->setting['medium_image_height'])) { $system_obj_cached->setting['medium_image_height'] = '120'; } if (!isset($system_obj_cached->setting['image_size_mb'])) { $system_obj_cached->setting['image_size_mb'] = '2'; } // update update_option('mgm_system', $system_obj_cached); // ends
<?php /** * Objects merge/update */ // read $obj_packs = mgm_get_option('subscription_packs'); $arr_packs = array(); foreach ($obj_packs->packs as $pack) { $active = $pack['active']; if (!is_array($active)) { $pack['active'] = array(); foreach ($obj_packs->get_active_options() as $option => $val) { $pack['active'][$option] = $active ? 1 : ($option != 'register' ? 1 : 0); } } $arr_packs[] = $pack; } if (!empty($arr_packs)) { $obj_packs->packs = $arr_packs; update_option('mgm_subscription_packs', $obj_packs); } //update nested shortcode parsing: $obj_settings = mgm_get_option('system'); if (!isset($obj_settings->setting['enable_nested_shortcode_parsing'])) { $obj_settings->setting['enable_nested_shortcode_parsing'] = 'Y'; update_option('mgm_system', $obj_settings); } // end file
function mgm_get_cached_object($class_name, $type, $id = false) { // on type switch ($type) { case 'payment': case 'autoresponder': return mgm_get_module($class_name, $type, true); break; case 'member': return mgm_get_member($id, true); // cached from db break; case 'post': return mgm_get_post($id, true); // cached from db break; case 'class': default: return mgm_get_option($class_name); break; } // error return false; }
<?php /** * Objects merge/update */ // new object $member_custom_fields =& new mgm_member_custom_fields(); // saved object $member_custom_fields_cached = mgm_get_option('member_custom_fields'); // before // mgm_log('before:'.print_r($member_custom_fields_cached,true)); // updated $updated = 0; // loop fresh foreach ($member_custom_fields->custom_fields as $custom_field) { // check if exists if ($member_custom_fields_cached->get_field_by_name($custom_field['name'], 'bool') == false) { // add new $member_custom_fields_cached->set_custom_field($custom_field); // added $updated++; } } // if updated if ($updated) { // update update_option('mgm_member_custom_fields', $member_custom_fields_cached); } // after // mgm_log('after:'.print_r($member_custom_fields_cached,true)); // read
<?php /** * Objects merge/update */ if (!class_exists('mgm_ccbill')) { mgm_import_dependency(MGM_MODULE_BASE_DIR . '/payment/ccbill/mgm_ccbill'); } // saved object $mgm_ccbill_cached = mgm_get_option('ccbill'); // edit var if ($mgm_ccbill_cached->supports_trial == 'N') { $mgm_ccbill_cached->supports_trial = 'Y'; } // update update_option('mgm_ccbill', $mgm_ccbill_cached); // ends
<?php /** * Objects merge/update */ // saved object $mgm_ideal_cached = mgm_get_option('ideal'); // set new vars // merchant id if (!isset($mgm_ideal_cached->setting['merchant_id'])) { $mgm_ideal_cached->setting['merchant_id'] = ''; } // subscription id if (!isset($mgm_ideal_cached->setting['sub_id'])) { $mgm_ideal_cached->setting['sub_id'] = ''; } // language if (!isset($mgm_ideal_cached->setting['language'])) { $mgm_ideal_cached->setting['language'] = ''; } // language if (!isset($mgm_ideal_cached->setting['aquirer'])) { $mgm_ideal_cached->setting['aquirer'] = ''; } // old username setting if (isset($mgm_ideal_cached->setting['username'])) { unset($mgm_ideal_cached->setting['username']); } //remove product mapping if ($mgm_ideal_cached->requires_product_mapping == 'Y') { $mgm_ideal_cached->requires_product_mapping = 'N';
$mgm_system_cached = mgm_get_option('system'); // set new vars // aws_enable_s3 if (!isset($mgm_system_cached->setting['aws_enable_s3'])) { $mgm_system_cached->setting['aws_enable_s3'] = $mgm_system->setting['aws_enable_s3']; } // aws_key if (!isset($mgm_system_cached->setting['aws_key'])) { $mgm_system_cached->setting['aws_key'] = $mgm_system->setting['aws_key']; } // aws_secret_key if (!isset($mgm_system_cached->setting['aws_secret_key'])) { $mgm_system_cached->setting['aws_secret_key'] = $mgm_system->setting['aws_secret_key']; } // update update_option('mgm_system', $mgm_system_cached); // read ======= // saved object // include logout_redirects array $mgm_mem_type_cached = mgm_get_option('membership_types'); if (!isset($mgm_mem_type_cached->logout_redirects)) { $mgm_mem_type_cached->logout_redirects = array(); update_option('mgm_membership_types', $mgm_mem_type_cached); } // include logout redirect url: $mgm_system_cached = mgm_get_option('system'); if (!isset($mgm_system_cached->setting['logout_redirect_url'])) { $mgm_system_cached->setting['logout_redirect_url'] = ''; update_option('mgm_system', $mgm_system_cached); } //end
<?php /** * Objects merge/update */ // read $obj_packs = mgm_get_option('subscription_packs'); if (!empty($obj_packs->duration_str) && !in_array(__('Lifetime', 'mgm'), $obj_packs->duration_str)) { // set $obj_packs->duration_str['l'] = __('Lifetime', 'mgm'); // update update_option('mgm_subscription_packs', $obj_packs); } // end file
<?php //fetch mgm_roles array from db: //initiall it was using to store mgm created roles $mgm_roles = get_option('mgm_roles'); if (is_array($mgm_roles)) { //replace mgm roles with mgm_created_roles update_option('mgm_created_roles', $mgm_roles); //save mgm_roles class object mgm_get_option('roles', true); }