本文整理匯總了PHP中PMProEmail::sendCreditCardExpiringEmail方法的典型用法代碼示例。如果您正苦於以下問題:PHP PMProEmail::sendCreditCardExpiringEmail方法的具體用法?PHP PMProEmail::sendCreditCardExpiringEmail怎麽用?PHP PMProEmail::sendCreditCardExpiringEmail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PMProEmail
的用法示例。
在下文中一共展示了PMProEmail::sendCreditCardExpiringEmail方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: pmpro_cron_credit_card_expiring_warnings
function pmpro_cron_credit_card_expiring_warnings()
{
global $wpdb;
$next_month_date = date("Y-m-01", strtotime("+2 months"));
$sqlQuery = "SELECT mu.user_id\n\t\t\t\t\t\tFROM {$wpdb->pmpro_memberships_users} mu\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->usermeta} um1 ON mu.user_id = um1.user_id\n\t\t\t\t\t\t\t\tAND meta_key = 'pmpro_ExpirationMonth'\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->usermeta} um2 ON mu.user_id = um2.user_id\n\t\t\t\t\t\t\t\tAND um2.meta_key = 'pmpro_ExpirationYear'\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->usermeta} um3 ON mu.user_id = um3.user_id\n\t\t\t\t\t\t\t\tAND um3.meta_key = 'pmpro_credit_card_expiring_warning'\n\t\t\t\t\t\tWHERE mu.status = 'active'\n\t\t\t\t\t\t\tAND mu.cycle_number >0\n\t\t\t\t\t\t\tAND CONCAT(um2.meta_value, '-', um1.meta_value, '-01') < '" . $next_month_date . "'\n\t\t\t\t\t\t\tAND (um3.meta_value IS NULL OR CONCAT(um2.meta_value, '-', um1.meta_value, '-01') <> um3.meta_value)\n\t\t\t\t\t";
$cc_expiring_user_ids = $wpdb->get_col($sqlQuery);
if (!empty($cc_expiring_user_ids)) {
require_once ABSPATH . 'wp-includes/pluggable.php';
foreach ($cc_expiring_user_ids as $user_id) {
//get user
$euser = get_userdata($user_id);
//make sure their level doesn't have a billing limit that's been reached
$euser->membership_level = pmpro_getMembershipLevelForUser($euser->ID);
if (!empty($euser->membership_level->billing_limit)) {
/*
There is a billing limit on this level, skip for now.
We should figure out how to tell if the limit has been reached
and if not, email the user about the expiring credit card.
*/
continue;
}
//make sure they are using a credit card type billing method for their current membership level (check the last order)
$last_order = new MemberOrder();
$last_order->getLastMemberOrder($euser->ID);
if (empty($last_order->accountnumber)) {
continue;
}
//okay send them an email
$send_email = apply_filters("pmpro_send_credit_card_expiring_email", true, $e->user_id);
if ($send_email) {
//send an email
$pmproemail = new PMProEmail();
$pmproemail->sendCreditCardExpiringEmail($euser);
printf(__("Credit card expiring email sent to %s. ", "pmpro"), $euser->user_email);
}
//update user meta so we don't email them again
update_user_meta($euser->ID, "pmpro_credit_card_expiring_warning", $euser->pmpro_ExpirationYear . "-" . $euser->pmpro_ExpirationMonth . "-01");
}
}
}