当前位置: 首页>>代码示例>>PHP>>正文


PHP PMProEmail::sendCreditCardExpiringEmail方法代码示例

本文整理汇总了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");
        }
    }
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:40,代码来源:crons.php


注:本文中的PMProEmail::sendCreditCardExpiringEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。