本文整理汇总了PHP中mgm_get_member函数的典型用法代码示例。如果您正苦于以下问题:PHP mgm_get_member函数的具体用法?PHP mgm_get_member怎么用?PHP mgm_get_member使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mgm_get_member函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createEmail
function createEmail($fileArr, $filecount)
{
$dbh = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME, $dbh);
$sql = "SELECT ID, user_email FROM wp_users";
$result = mysql_query($sql, $dbh);
while ($IDs = mysql_fetch_array($result)) {
$mgm_member = mgm_get_member($IDs[0]);
if ($mgm_member->status == 'Active') {
$s2_custom_fields = get_user_option('s2member_custom_fields', $IDs[0]);
$tracks2email = $s2_custom_fields['tracks2email'];
if ($tracks2email != "") {
$tracks2emailArr = explode(",", $tracks2email);
// gives an array of selected tracks of this user
$user_info = get_userdata($IDs[0]);
$email = $user_info->user_email;
$first_name = $user_info->first_name;
$string = "";
foreach ($tracks2emailArr as $trackCode) {
foreach ($fileArr as $trackFile) {
if (substr($trackFile, 0, 3) == $trackCode) {
$string .= getTrackName($trackCode) . " - " . getRaceDateText(substr($trackFile, 3, 6)) . '<a target="_blank" href="http://hotdogs.com.au/format/functions/createpdf.php?file=' . $trackFile . '" class="trackdownload" > Download </a><br />';
}
}
}
if ($string != "") {
sendTrackEmail($email, $first_name, $string);
}
echo $email . "<br/>";
//}
}
}
//if active memeber
}
}
示例2: mgm_patch_get_users
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;
}
示例3: mgm_get_payment_subscribe_page_html
/**
* get payment subscribe page html
*
* @param void
* @return string
* @since 1.5
*/
function mgm_get_payment_subscribe_page_html()
{
// attach scripts, returns
do_action('mgm_attach_scripts');
// content
$html = sprintf('<p>%s</p>', __('You are already subscribed or an error occurred. Please contact an administrator for more information.', 'mgm'));
// get user query string
$user = mgm_get_user_from_querystring();
// member
if (isset($user) && is_object($user)) {
$member = mgm_get_member($user->ID);
}
// action
$action = mgm_get_var('action', '', true);
// print
if (!empty($action) && count(mgm_get_class('membership_types')->membership_types) > 0) {
// upgrade or complete
if (in_array($action, array('upgrade', 'complete_payment'))) {
$html = mgm_get_upgrade_buttons();
// extend
} elseif ($action == 'extend') {
$html = mgm_get_extend_button();
// extend
} elseif ($action == 'purchase_another') {
$html = mgm_get_purchase_another_subscription_button();
//TODO
// bad action
} else {
$html = sprintf('<p>%s</p>', sprintf(__('Error - Unknown action - "%s", Exiting...', 'mgm'), $action));
}
} elseif (isset($member) && is_object($member) && in_array($member->status, array(MGM_STATUS_NULL, MGM_STATUS_EXPIRED, MGM_STATUS_TRIAL_EXPIRED))) {
$html = mgm_get_subscription_buttons($user, true);
} elseif (isset($member) && is_object($member) && $member->status == MGM_STATUS_PENDING) {
$html = sprintf('<p>%s</p>', __('Error - Your subscription status is pending. Please contact an administrator for more information.', 'mgm'));
}
// return
return apply_filters('mgm_payment_subscribe_page_html', $html);
}
示例4: updateUserDetails
/**
* This will update user expirey date/status if any issues
* @param $user_id
*/
function updateUserDetails($user_id = null)
{
if (is_numeric($user_id)) {
$users[] = $user_id;
} else {
$users = mgm_get_all_userids();
}
//mgm_log(mgm_array_dump($users, true));
$arr_skip = array('guest', 'free', 'trial');
foreach ($users as $user_id) {
$member = mgm_get_member($user_id);
if (!isset($member->membership_type) || isset($member->membership_type) && in_array(strtolower($member->membership_type), $arr_skip)) {
continue;
}
if (strtolower($member->status) == 'cancelled') {
//mgm_log($user_id, 'not_updated_cacncelled', true);
}
if (isset($member->payment_info->subscr_id) && !empty($member->payment_info->subscr_id)) {
$update = $this->getSaleDetails($member->payment_info->subscr_id);
$update['user_id'] = $user_id;
if ($update['status'] == 'active') {
if (strtotime($update['expire_date']) >= strtotime(date('Y-m-d'))) {
$update['user_id'] = $user_id;
//mgm_log(mgm_array_dump($update, true), 'updated-users', true);
$member->expire_date = $update['expire_date'];
$member->status = MGM_STATUS_ACTIVE;
$member->status_str = __('Last payment was successful', 'mgm');
$member->last_pay_date = $update['last_pay'];
$member->save();
} else {
//mgm_log(mgm_array_dump($update, true), 'not_updated_past_date', true);
}
} else {
//mgm_log(mgm_array_dump($update, true), 'not_updated_no_details', true);
}
} else {
//mgm_log($user_id, 'not_updated_no_saleid', true);
}
}
}
示例5: _verify_member_for_upgrade
function _verify_member_for_upgrade($user_id)
{
// get member
$member = mgm_get_member((int) $user_id);
// validate
if ($member->payment_info->subscr_id == $_POST['originalSubscriptionId']) {
// valid
return true;
}
// return
return false;
}
示例6: cancel_recurring_subscription
/**
* Cancel Recurring Subscription
* This is not a private function
* @param int/string $trans_ref
* @param int $user_id
* @param int/string $subscr_id
* @return boolean
*/
function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null)
{
//if coming form process return after a subscription payment
if (!empty($trans_ref)) {
$transdata = $this->_get_transaction_passthrough($trans_ref);
if ($transdata['payment_type'] != 'subscription_purchase') {
return false;
}
$user_id = $transdata['user_id'];
if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') {
$member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']);
} else {
$member = mgm_get_member($user_id);
}
if (isset($member->payment_info->module) && !empty($member->payment_info->module)) {
if (isset($member->payment_info->subscr_id)) {
$subscr_id = $member->payment_info->subscr_id;
} else {
//check pack is recurring:
$pid = $pack_id ? $pack_id : $member->pack_id;
if ($pid) {
$s_packs = mgm_get_class('subscription_packs');
$sel_pack = $s_packs->get_pack($pid);
if ($sel_pack['num_cycles'] != 1) {
$subscr_id = 0;
}
}
}
//check for same module: if not call the same function of the applicale module.
if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) {
// log
// mgm_log('RECALLing '. $member->payment_info->module .': cancel_recurring_subscription FROM: ' . $this->code);
// return
return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id);
}
//skip if same pack is updated
if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) {
return false;
}
} else {
return false;
}
}
//only for subscription_purchase
if ($subscr_id) {
// set xml content
$post_data = '<ARBCancelSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>' . $this->setting['loginid'] . '</name>
<transactionKey>' . $this->setting['tran_key'] . '</transactionKey>
</merchantAuthentication>
<refId>' . $user_id . '</refId>
<subscriptionId>' . $subscr_id . '</subscriptionId>
</ARBCancelSubscriptionRequest>';
// end point
$endpoint = $this->_get_endpoint($this->status . '_arb');
// test_arb, live_aim etc.
// headers
$http_headers = array('Content-Type' => 'text/xml');
// create curl post
$http_response = mgm_remote_post($endpoint, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false));
// parse response and store into a different array:
// do not use $this->response here as this will overwrite previous theprevious values in one scenario
$arb_response = $this->_process_response('arb', $http_response, false);
// check
if (isset($arb_response['response_status']) && $arb_response['response_status'] == 1) {
return true;
}
} elseif (is_null($subscr_id) || $subscr_id === 0) {
//send email to admin if subscription Id is absent
$system_obj = mgm_get_class('system');
$dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
//send email only if setting enabled
if (!$dge) {
// blog
$blogname = get_option('blogname');
// user
$user = get_userdata($user_id);
// notify admin
mgm_notify_admin_membership_cancellation_manual_removal_required($blogname, $user, $member);
}
// return
return true;
}
// return
return false;
}
示例7: cancel_recurring_subscription
/**
* Cancel Recurring Subscription
* This is not a private function
* @param int/string $trans_ref
* @param int $user_id
* @param int/string $subscr_id
* @return boolean
*/
function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null)
{
global $wpdb;
//if coming form process return after a subscription payment
if (!empty($trans_ref)) {
$transdata = $this->_get_transaction_passthrough($trans_ref);
if ($transdata['payment_type'] != 'subscription_purchase') {
return false;
}
$user_id = $transdata['user_id'];
if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') {
$member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']);
} else {
$member = mgm_get_member($user_id);
}
if (isset($member->payment_info->module) && !empty($member->payment_info->module)) {
if (isset($member->payment_info->subscr_id)) {
$subscr_id = $member->payment_info->subscr_id;
} else {
//check pack is recurring:
$pid = $pack_id ? $pack_id : $member->pack_id;
if ($pid) {
$s_packs = mgm_get_class('subscription_packs');
$sel_pack = $s_packs->get_pack($pid);
if ($sel_pack['num_cycles'] != 1) {
$subscr_id = 0;
}
}
}
//check for same module: if not call the same function of the applicale module.
if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) {
// log
// mgm_log('RECALLing '. $member->payment_info->module .': cancel_recurring_subscription FROM: ' . $this->code);
// return
return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id);
}
//skip if same pack is updated
if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) {
return false;
}
} else {
return false;
}
}
//only for subscription_purchase
if ($pack_id && $user_id) {
$userInfo = get_userdata($user_id);
$client_cache = $wpdb->get_results($wpdb->prepare('SELECT paymill_sub_id FROM ' . $wpdb->prefix . 'paymill_subscriptions WHERE mgm_user_id="%s" AND mgm_offer_id="%s"', array($user_id, $pack_id)), ARRAY_A);
if (isset($client_cache[0]['paymill_sub_id']) && strlen($client_cache[0]['paymill_sub_id']) > 0) {
$this->subscriptions->remove($client_cache[0]['paymill_sub_id']);
$query = $wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'paymill_subscriptions WHERE mgm_user_id="%s" AND mgm_offer_id="%s"', array($user_id, $pack_id));
$wpdb->query($query);
return true;
} else {
return false;
}
}
return false;
}
示例8: mgm_get_class
$new_type_code = $membership_types_obj->get_type_code($type_name);
//check
if ($new_type_code != $type_code) {
// get object
$obj_sp = mgm_get_class('subscription_packs');
//update new
foreach ($obj_sp->packs as $key => $pack) {
if ($obj_sp->packs[$key]['membership_type'] == $type_code) {
$obj_sp->packs[$key]['membership_type'] = $new_type_code;
$obj_sp->save();
}
}
// loop
foreach ($users as $user) {
// get
$member = mgm_get_member($user->ID);
// if users with same membershiptype as that of selected
if (isset($member->membership_type) && $member->membership_type == $type_code) {
// set
$member->membership_type = $new_type_code;
// save
$member->save();
}
// check if any multiple levels exist:
if (isset($member->other_membership_types) && is_array($member->other_membership_types) && count($member->other_membership_types) > 0) {
// loop
foreach ($member->other_membership_types as $key => $memtypes) {
// make sure its an object:
$memtypes = mgm_convert_array_to_memberobj($memtypes, $user->ID);
// verify
if ($memtypes->membership_type == $type_code) {
示例9: mgm_update_coupon_usage_process
/**
* Updating coupon usage for register coupon only
*
* @param array $args
* @return void
*/
function mgm_update_coupon_usage_process($args = array())
{
global $wpdb;
// check
if (isset($args['user_id'])) {
// user_id
$user_id = $args['user_id'];
$member = mgm_get_member($user_id);
// check
if (isset($member->coupon['update_usage']) && $member->coupon['update_usage']) {
if (isset($member->coupon['coupon_usage_id']) && $member->coupon['coupon_usage_id']) {
// id
$coupon_id = $member->coupon['coupon_usage_id'];
// update
mgm_update_coupon_usage($coupon_id, 'after_payment');
// once done reset the same since all type of coupon uses the same
$member->coupon['coupon_usage_id'] = false;
$member->coupon['update_usage'] = false;
$member->save();
}
}
}
// check - issue #1421
if (isset($args['guest_token'])) {
//coupon_id
$coupon_id = isset($args['coupon_id']) ? $args['coupon_id'] : 0;
// update
mgm_update_coupon_usage($coupon_id, 'after_payment');
}
}
示例10: cancel_recurring_subscription
/**
* Cancel Recurring Subscription
* This is not a private function
* @param int/string $trans_ref
* @param int $user_id
* @param int/string $subscr_id
* @return boolean
*/
function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null)
{
//if coming form process return after a subscription payment
if (!empty($trans_ref)) {
$transdata = $this->_get_transaction_passthrough($trans_ref);
if ($transdata['payment_type'] != 'subscription_purchase') {
return false;
}
$user_id = $transdata['user_id'];
if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') {
$member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']);
} else {
$member = mgm_get_member($user_id);
}
if (isset($member->payment_info->module) && !empty($member->payment_info->module)) {
if (isset($member->payment_info->subscr_id)) {
$subscr_id = $member->payment_info->subscr_id;
} else {
//check pack is recurring:
$pid = $pack_id ? $pack_id : $member->pack_id;
if ($pid) {
$s_packs = mgm_get_class('subscription_packs');
$sel_pack = $s_packs->get_pack($pid);
if ($sel_pack['num_cycles'] != 1) {
$subscr_id = 0;
}
// 0 stands for a lost subscription id
}
}
//check for same module: if not call the same function of the applicale module.
if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) {
// mgm_log('RECALLing '. $member->payment_info->module .': cancel_recurring_subscription FROM: ' . $this->code);
return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id);
}
//skip if same pack is updated
if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) {
return false;
}
} else {
return false;
}
}
//ony for subscription_purchase
if ($subscr_id) {
// end point
$endpoint = $this->_get_endpoint('unsubscribe');
// base
// add query
$url = add_query_arg(array('SUBSCRIPTION_ID' => urlencode($subscr_id), 'MERCHANT_ID' => urlencode($this->setting['merchant_id']), 'ZombaioGWPass' => urlencode($this->setting['gw_pass']), 'ReasonCode' => urlencode(11)), $endpoint);
// create curl post
//$buffer = $this->_curl_post($url);
// headers
$http_headers = array();
// fetch
$http_response = mgm_remote_post($url, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false));
// verify
if ($http_response == 1) {
return true;
} else {
// message
return $this->_get_cancel_error($http_response);
}
} elseif ($subscr_id === 0) {
//send email to admin if subscription Id is absent
$system_obj = mgm_get_class('system');
$dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
//send email only if setting enabled
if (!$dge) {
$user = get_userdata($user_id);
//send notification email to admin:
$message = __('The User: ', 'mgm') . $user->user_email . ' (' . $user_id . ') ' . __('has upgraded/cancelled subscription.', 'mgm');
$message .= "<br/>" . __('Please unsubscribe the user subscription from Gateway Merchant panel.', 'mgm');
if (!empty($member->transaction_id)) {
$message .= "<br/>" . __('MGM Transaction Id:', 'mgm') . $member->transaction_id;
}
//admin email:
if (!empty($system_obj->setting['admin_email'])) {
@mgm_mail($system_obj->setting['admin_email'], sprintf(__('[%s] User Subscription Cancellation', 'mgm'), get_option('blogname')), $message);
}
}
return true;
}
return false;
}
示例11: mgm_get_all_userids
<?php
/**
* Objects merge/update
*/
//Restoring custom 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);
// save
if (isset($member->custom_fields)) {
foreach ($member->custom_fields as $key => $value) {
// key
$options_key = '_mgm_cf_' . $key;
// verify
if ($user_id) {
// update
update_user_option($user_id, $options_key, $value, true);
}
}
}
}
}
// end file
示例12: _confirm_notify
/**
* Confirm notify URL.
*
* related to issue#: 528
* As PAYPALPRO doesn't use overridden notifyurl, and posts IPN to default IPN settings URL on merchant panel
* Confirm module field in transactions table/mgm_member object
*
*/
function _confirm_notify()
{
$mod_code = '';
//check possible params for transaction id [rp_invoice_id, invoice, custom]
if (isset($_POST['rp_invoice_id']) && is_numeric($_POST['rp_invoice_id'])) {
$transaction_id = $_POST['rp_invoice_id'];
} elseif (isset($_POST['invoice']) && is_numeric($_POST['invoice'])) {
$transaction_id = $_POST['invoice'];
} elseif (isset($_POST['custom']) && is_numeric($_POST['custom'])) {
$transaction_id = $_POST['custom'];
} elseif (isset($_POST['custom']) && !is_numeric($_POST['custom']) && preg_match('/^subscription_/', $_POST['custom'])) {
//for backward compatibility:
//transaction cannot be found for old users:
$transdata = $this->_get_transaction_passthrough($_POST['custom']);
$member = mgm_get_member($transdata['user_id']);
if (isset($member->payment_info->module) && !empty($member->payment_info->module)) {
$mod_code = preg_match('/mgm_/', $member->payment_info->module) ? $member->payment_info->module : 'mgm_' . $transdata['module'];
}
}
//if a transaction id is found
if (isset($transaction_id)) {
$transdata = mgm_get_transaction($transaction_id);
if (!empty($transdata['module'])) {
$mod_code = preg_match('/mgm_/', $transdata['module']) ? $transdata['module'] : 'mgm_' . $transdata['module'];
}
}
//if module code is found and not belongs to current module, then invode process_notify() function of the applicable module.
if (!empty($mod_code) && $mod_code != $this->code) {
// recall process_notifyof the module
// keep the log untill paypal is resolved.
// mgm_log('FROM PAYMENT: recalling ' . $mod_code .'->process_notify() FROM: '. $this->code );
mgm_get_module($mod_code, 'payment')->process_notify();
// return
return false;
}
return true;
}
示例13: mgm_member_sort
function mgm_member_sort($field, $order_type, $sql_filter, $super_adminids = array())
{
global $wpdb;
$super_admin_in = count($super_adminids) == 0 ? 0 : implode(',', $super_adminids);
// get members
$sql = "SELECT SQL_CALC_FOUND_ROWS `ID` FROM `{$wpdb->users}` WHERE ID NOT IN ({$super_admin_in}) {$sql_filter}";
//users
$users = $wpdb->get_results($sql);
// init
$members = array();
//sorted members
$sorted_members = array();
// check
if ($users) {
// loop
foreach ($users as $user) {
// member object
$member = mgm_get_member($user->ID);
switch ($field) {
case 'last_pay_date':
case 'expire_date':
// from custom field
if (isset($member->{$field}) && !empty($member->{$field})) {
$members[$user->ID] = date('Y-m-d', strtotime($member->{$field}));
} else {
$members[$user->ID] = '';
}
break;
}
unset($member);
}
}
//sort the array
if (strtolower($order_type) == 'desc') {
arsort($members);
}
if (strtolower($order_type) == 'asc') {
asort($members);
}
if (!empty($members)) {
foreach ($members as $key => $value) {
$sorted_members[] = $key;
}
}
// return
return $sorted_members;
}
示例14: _buy_membership
function _buy_membership($transid = null)
{
// system
$system_obj = mgm_get_class('system');
$s_packs = mgm_get_class('subscription_packs');
// get details
//if transaction id is available:
if (is_numeric($transid)) {
$custom = $this->_get_transaction_passthrough($transid);
extract($custom);
// mgm_log($custom);
} else {
//Purchase Another Membership Level problem : issue #: 752
$is_another_membership_purchase = 'N';
$parts = explode('_', $_REQUEST['custom']);
$params = array('user_id' => 0, 'duration' => '', 'duration_type' => '', 'pack_id' => 0, 'is_another_membership_purchase' => 'N', 'membership_type' => '');
$i = 0;
foreach ($params as $param => $default) {
if (isset($parts[$i])) {
${$param} = $parts[$i];
} else {
${$param} = $default;
}
$i++;
}
}
// get pack
$pack = $s_packs->get_pack($pack_id);
// membership_type -issue #1005
if (empty($membership_type)) {
$membership_type = $pack['membership_type'];
}
// user
if ($user = get_userdata($user_id)) {
//Purchase Another Membership Level problem : issue #: 752
if ($is_another_membership_purchase == 'Y') {
// another_subscription modification
//issue #1073
$member = mgm_get_member_another_purchase($user_id, $membership_type);
} else {
// get member
$member = mgm_get_member($user_id);
}
//pack currency over rides genral setting currency - issue #1602
if (isset($pack['currency']) && !empty($pack['currency'])) {
$currency = $pack['currency'];
} else {
$currency = $system_obj->setting['currency'];
}
// check
//uncommented the below line as it is not updating in upgrade subscription
//if (!$member->duration) {
$member->duration = $duration ? $duration : 1;
// one year
$member->duration_type = $duration_type ? $duration_type : 'y';
$member->amount = 0.0;
//$member->currency = 'USD';//not sure y hardcoded
$member->currency = $currency;
$member->membership_type = $membership_type;
//}
// set pack
$member->pack_id = $pack_id;
$member->active_num_cycles = isset($num_cycles) && !empty($num_cycles) ? $num_cycles : $pack['num_cycles'];
// set status
$member->status = MGM_STATUS_ACTIVE;
$member->account_desc = __('Free Account', 'mgm');
$member->last_pay_date = '';
//reset payment_info if already set:
if (isset($member->payment_info)) {
unset($member->payment_info);
}
//unset rebill:
if (isset($member->rebilled)) {
unset($member->rebilled);
}
//unset transaction_id:
if (isset($member->transaction_id)) {
unset($member->transaction_id);
}
// join date
$time = time();
// set
if (!isset($member->join_date) || isset($member->join_date) && empty($member->join_date)) {
$member->join_date = $time;
}
// old content hide - issue #1227
if (isset($hide_old_content)) {
$member->hide_old_content = $hide_old_content;
}
// type expanded
$duration_exprs = $s_packs->get_duration_exprs();
// if not lifetime/date range
if (in_array($member->duration_type, array_keys($duration_exprs))) {
// take only date exprs
// @TODO, time should be last expire date #773, 3 use cases must be tracked
// expect new param in tran subscription_type: new, upgrade, downgrade, extend
$expire_date_ts = !$member->expire_date ? $time : strtotime($member->expire_date);
// time
$expire_date_ts = strtotime("+{$member->duration} {$duration_exprs[$member->duration_type]}", $expire_date_ts);
// formatted
//.........这里部分代码省略.........
示例15: mgm_get_purchase_another_subscription_button
/**
* create purchase another button
*
* @param array userdata
* @retun string html output
*/
function mgm_get_purchase_another_subscription_button($args = array())
{
global $wpdb;
//ceck settings
$settings = mgm_get_class('system')->get_setting();
// check
if (!isset($settings['enable_multiple_level_purchase']) || isset($settings['enable_multiple_level_purchase']) && !bool_from_yn($settings['enable_multiple_level_purchase'])) {
return;
}
// current user
$user = wp_get_current_user();
// validate
if (!$user->ID) {
// query string
$user = mgm_get_user_from_querystring();
}
// validate
if (!$user->ID) {
return __('No such user', 'mgm');
}
// userdata
$username = $user->user_login;
$mgm_home = get_option('siteurl');
$member = mgm_get_member($user->ID);
$system_obj = mgm_get_class('system');
$membership_type = mgm_get_user_membership_type($user->ID, 'code');
$packs_obj = mgm_get_class('subscription_packs');
$packs = $packs_obj->get_packs('upgrade');
$duration_str = $packs_obj->duration_str;
$trial_taken = $member->trial_taken;
// pack_ids
$pack_ids = mgm_get_members_packids($member);
$pack_membership_types = mgm_get_subscribed_membershiptypes($user->ID, $member);
// query_arg
$form_action = mgm_get_custom_url('transactions', false, array('action' => 'purchase_another', 'username' => $username));
//issue 1009
if (isset($settings['membership_details_url'])) {
$membership_details_url = $settings['membership_details_url'];
} else {
$membership_details_url = get_admin_url() . 'profile.php?page=mgm/profile';
}
// cancel
$cancel_url = $membership_details_url;
// $cancel_url = mgm_get_custom_url('membership_details');
// active modules
$a_payment_modules = $system_obj->get_active_modules('payment');
// selected_subscription
$selected_subs = mgm_get_selected_subscription($args);
// second step, after post
if (isset($_POST['submit'])) {
// verify selected
if (!isset($_POST['subs_opt'])) {
// die
return sprintf(__('Package not selected, <a href="%s">go back</a>.', 'mgm'), $_POST['form_action']);
exit;
}
// get subs data
$subs_opt_pack = mgm_decode_package($_POST['subs_opt']);
extract($subs_opt_pack);
// check
$valid = false;
// loop packs
foreach ($packs as $pack) {
// check
//check pack id as well: issue#: 580
if ($pack['cost'] == $cost && $pack['duration'] == $duration && $pack['duration_type'] == $duration_type && $membership_type == $pack['membership_type'] && $pack_id == $pack['id']) {
$valid = true;
break;
}
}
// error
if (!$valid) {
return __('Invalid data passed', 'mgm');
exit;
}
// get object
$member = new mgm_member($user->ID);
$temp_membership = $member->_default_fields();
$temp_membership['membership_type'] = $membership_type;
$temp_membership['pack_id'] = $pack_id;
//issue #860
//if (isset($_POST['mgm_upgrade_field']['autoresponder']) && ($_POST['mgm_upgrade_field']['autoresponder'])=='Y') {
if (isset($_POST['mgm_upgrade_field']['autoresponder']) && substr($_POST['mgm_upgrade_field']['autoresponder'], 0, 1) == 'Y') {
$temp_membership['subscribed'] = 'Y';
$temp_membership['autoresponder'] = $system_obj->active_modules['autoresponder'];
}
//issue #1236
if (isset($_POST['mgm_upgrade_field']['coupon']) && !empty($_POST['mgm_upgrade_field']['coupon'])) {
//issue #1250 - Coupon validation
if (!empty($_POST['form_action'])) {
// check if its a valid coupon
if (!($coupon = mgm_get_coupon_data($_POST['mgm_upgrade_field']['coupon']))) {
//redirect back to the form
$q_arg = array('error_field' => 'Coupon', 'error_type' => 'invalid', 'error_field_value' => $_POST['mgm_upgrade_field']['coupon']);
//.........这里部分代码省略.........