Exemplo n.º 1
0
 function wpestate_check_user_membership_status_function()
 {
     $blogusers = get_users('role=subscriber');
     foreach ($blogusers as $user) {
         $user_id = $user->ID;
         $pack_id = get_user_meta($user_id, 'package_id', true);
         if ($pack_id != '') {
             // if the pack is ! free
             $date = strtotime(get_user_meta($user_id, 'package_activation', true));
             $biling_period = get_post_meta($pack_id, 'biling_period', true);
             $billing_freq = get_post_meta($pack_id, 'billing_freq', true);
             $seconds = 0;
             switch ($biling_period) {
                 case 'Day':
                     $seconds = 60 * 60 * 24;
                     break;
                 case 'Week':
                     $seconds = 60 * 60 * 24 * 7;
                     break;
                 case 'Month':
                     $seconds = 60 * 60 * 24 * 30;
                     break;
                 case 'Year':
                     $seconds = 60 * 60 * 24 * 365;
                     break;
             }
             $time_frame = $seconds * $billing_freq;
             $now = time();
             if ($now > $date + $time_frame) {
                 // if this moment is bigger than pack activation + billing period
                 wpestate_downgrade_to_free($user_id);
             }
         }
         // end if if pack !- free
     }
     // end foreach
     wpestate_check_free_listing_expiration();
 }
Exemplo n.º 2
0
            // payment already processd
            exit;
        }
        if ($user_id == 0) {
            // no user with such profile id
            exit;
        }
        if ($amount != $price) {
            // received payment diffrent than pack value
            exit;
        }
        wpestate_upgrade_user_membership($user_id, $pack_id, 2, $txn_id);
    } else {
        // payment not completed
        if ($txn_type != 'recurring_payment_profile_created') {
            wpestate_downgrade_to_free($user_id);
        }
    }
} else {
    exit('not right');
}
/////////////////////////////////////////////////////////////////////////////////////
// get user by paypal recurring profile
/////////////////////////////////////////////////////////////////////////////////////
function wpestate_retrive_user_by_profile($recurring_payment_id)
{
    $recurring_payment_id = str_replace('-', 'xxx', $recurring_payment_id);
    $arg = array('role' => 'subscriber', 'meta_key' => 'profile_id', 'meta_value' => $recurring_payment_id, 'meta_compare' => '=');
    $userid = 0;
    $blogusers = get_users($arg);
    foreach ($blogusers as $user) {