コード例 #1
0
 function read()
 {
     // get vars
     if (!$this->options) {
         // key
         $options_key = 'mgm_member_options';
         // verify
         if ($this->id) {
             // read
             $this->options = mgm_get_user_option($options_key, $this->id);
             // allow hook
             do_action('mgm_user_options_read', $this->options, $this->id);
             // sync saved vars with class vars
             return $this->_sync();
         }
     }
     // error
     return false;
 }
コード例 #2
0
function mgm_fix_member_classes($users)
{
    // key
    $class_name = 'mgm_member';
    $option = sprintf('%s_options', $class_name);
    // last id
    $last_id = NULL;
    // fix classes
    foreach ($users as $user) {
        // check
        if (!mgm_get_user_option($option, $user->user_id)) {
            // object
            if ($class_obj = mgm_get_cached_object($class_name, 'member', $user->user_id)) {
                // get new class/module
                $new_class_obj = mgm_get_member($user->user_id);
                // apply fix
                $new_class_obj->apply_fix($class_obj);
                // unset both
                unset($class_obj, $new_class_obj);
            }
        }
        // set
        $last_id = $user->user_id;
    }
    // return
    return $last_id;
}
コード例 #3
0
<?php

/** 
 * Objects merge/update
 */
//Restoring user _mgm_user_billing_num_cycles fileds to user meta
$arr_users = mgm_get_all_userids();
if (!empty($arr_users)) {
    foreach ($arr_users as $user_id) {
        //member
        $member = mgm_get_member($user_id);
        if (mgm_get_user_option('_mgm_user_billing_num_cycles', $user_id)) {
            // init
            $user_billing_num_cycles = 'ongoing';
            // ongoing
            // check limited
            if (isset($member->active_num_cycles) && (int) $member->active_num_cycles >= 1) {
                // set
                $user_billing_num_cycles = (int) $member->active_num_cycles;
            } else {
                // check pack
                if (isset($member->pack_id) && (int) $member->pack_id > 0) {
                    // set
                    if ($pack = mgm_get_class('subscription_packs')->get_pack($member->pack_id)) {
                        if (isset($pack['num_cycles']) && (int) $pack['num_cycles'] >= 1) {
                            $user_billing_num_cycles = (int) $pack['num_cycles'];
                        }
                    }
                }
            }
            // update
コード例 #4
0
     }
 }
 // othe membership level
 if (isset($member->other_membership_types) && !empty($member->other_membership_types) && is_object($member)) {
     //loop
     foreach ($member->other_membership_types as $key => $other_membership_type) {
         //filter for empty values
         $other_membership_type = array_filter($other_membership_type);
         //check
         if (!empty($other_membership_type)) {
             // convet
             if (is_array($other_membership_type)) {
                 $other_membership_type = mgm_convert_array_to_memberobj($other_membership_type, $user_id);
             }
             //check
             if (mgm_get_user_option(sprintf('mgm_user_billing_num_cycles_%d', $other_membership_type->pack_id), $user_id) === FALSE) {
                 //othermembership level wise user meta - issue #1681
                 if (isset($other_membership_type->pack_id) && (int) $other_membership_type->pack_id > 0) {
                     // init
                     $user_billing_num_cycles = 'ongoing';
                     // ongoing
                     // check limited
                     if (isset($other_membership_type->active_num_cycles) && (int) $other_membership_type->active_num_cycles >= 1) {
                         // set
                         $user_billing_num_cycles = (int) $other_membership_type->active_num_cycles;
                     } else {
                         // check pack
                         if (isset($other_membership_type->pack_id) && (int) $other_membership_type->pack_id > 0) {
                             // set
                             if ($pack = mgm_get_class('subscription_packs')->get_pack($other_membership_type->pack_id)) {
                                 if (isset($pack['num_cycles']) && (int) $pack['num_cycles'] >= 1) {
コード例 #5
0
            //loop
            foreach ($member->other_membership_types as $other_membership_type) {
                //filter for empty values
                $other_membership_type = array_filter($other_membership_type);
                //check
                if (!empty($other_membership_type)) {
                    //other members upgrade
                    if (isset($other_membership_type['upgrade']['coupon']['id']) && !empty($other_membership_type['upgrade']['coupon']['id']) && mgm_get_user_option($coupon_id . '_mgm_user_upgrade_coupon', $user_id) === FALSE) {
                        $coupon_id = (int) $other_membership_type['upgrade']['coupon']['id'];
                        //check
                        //if( mgm_get_user_option($coupon_id.'_mgm_user_upgrade_coupon', $user_id) === FALSE ){
                        // update
                        update_user_option($user_id, $coupon_id . '_mgm_user_upgrade_coupon', $coupon_id, true);
                        //}
                    }
                    //other members extend
                    if (isset($other_membership_type['extend']['coupon']['id']) && !empty($other_membership_type['extend']['coupon']['id']) && mgm_get_user_option($coupon_id . '_mgm_user_extend_coupon', $user_id) === FALSE) {
                        $coupon_id = (int) $other_membership_type['extend']['coupon']['id'];
                        //check
                        //if( mgm_get_user_option($coupon_id.'_mgm_user_extend_coupon', $user_id) === FALSE ){
                        // update
                        update_user_option($user_id, $coupon_id . '_mgm_user_extend_coupon', $coupon_id, true);
                        //}
                    }
                }
            }
        }
        unset($member);
        unset($user_id);
    }
}
コード例 #6
0
/** 
 * member object write action, used to copy member data to metadata for easy user query
 * 
 * @param array $options saved in usermeta
 * @param int user_id
 * @return void	
 * @since 2.7
 */
function mgm_user_options_sync_save($options, $user_id)
{
    // name
    // $filename = ('user_' . $user_id . '_' .__FUNCTION__);
    // log
    // mgm_log($options, $filename);
    // set status if changed
    if (isset($options['status']) && !empty($options['status'])) {
        // check
        if ($options['status'] != mgm_get_user_option('_mgm_user_status', $user_id)) {
            // update
            update_user_option($user_id, '_mgm_user_status', $options['status'], true);
        }
    }
}