Esempio n. 1
0
 function fix_expire_date()
 {
     // fix
     mgm_fix_member_expire_date($this);
 }
/** 
 *convert array to mgm_member object to be used as $member object
 * This is specifically for multiple membership type
 *
 * @package MagicMembers
 * @since 2.5
 * @param $member, array  
 * @return array
 */
function mgm_convert_array_to_memberobj($member_options, $user_id, $attach_id = true, $recursive = true)
{
    // init
    $member = new stdClass();
    // array
    if (is_array($member_options) && !empty($member_options)) {
        // loop
        foreach ($member_options as $key => $value) {
            // check
            if ($recursive && (is_array($value) || is_object($value))) {
                // #1312 coupons
                if (in_array($key, array('coupon', 'upgrade', 'extend'))) {
                    $member->{$key} = $value;
                } else {
                    $member->{$key} = mgm_convert_array_to_memberobj($value, $user_id, false, true);
                }
            } else {
                $member->{$key} = $value;
            }
        }
    }
    // attach id:
    if ($attach_id) {
        $member->id = $user_id;
    }
    // fix expire date
    mgm_fix_member_expire_date($member);
    // return
    return $member;
}