function sendToPayFast(&$order) { global $pmpro_currency; //taxes on initial amount $initial_payment = $order->InitialPayment; $initial_payment_tax = $order->getTaxForPrice($initial_payment); $initial_payment = round((double) $initial_payment + (double) $initial_payment_tax, 2); //taxes on the amount $amount = $order->PaymentAmount; $amount_tax = $order->getTaxForPrice($amount); $order->subtotal = $amount; $amount = round((double) $amount + (double) $amount_tax, 2); //build PayFast Redirect $environment = pmpro_getOption("gateway_environment"); if ("sandbox" === $environment || "beta-sandbox" === $environment) { $merchant_id = self::SANDBOX_MERCHANT_ID; $merchant_key = self::SANDBOX_MERCHANT_KEY; $payfast_url = "https://sandbox.payfast.co.za/eng/process"; } else { $merchant_id = pmpro_getOption("payfast_merchant_id"); $merchant_key = pmpro_getOption("payfast_merchant_key"); $payfast_url = "https://www.payfast.co.za/eng/process"; } $data = array('merchant_id' => $merchant_id, 'merchant_key' => $merchant_key, 'return_url' => pmpro_url("confirmation", "?level=" . $order->membership_level->id), 'cancel_url' => '', 'notify_url' => admin_url("admin-ajax.php") . "?action=payfast_itn_handler", 'name_first' => $order->FirstName, 'name_last' => $order->LastName, 'email_address' => $order->Email, 'm_payment_id' => $order->code, 'amount' => number_format($initial_payment, 2), 'item_name' => substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127)); $pfOutput = ""; foreach ($data as $key => $val) { $pfOutput .= $key . '=' . urlencode(trim($val)) . '&'; } // Remove last ampersand $pfOutput = substr($pfOutput, 0, -1); $signature = md5($pfOutput); $payfast_url .= '?' . $pfOutput . '&signature=' . $signature; wp_redirect($payfast_url); exit; }
function pmpro_send_html($phpmailer) { // Set the original plain text message $phpmailer->AltBody = wp_specialchars_decode($phpmailer->Body, ENT_QUOTES); // Clean < and > around text links in WP 3.1 $phpmailer->Body = preg_replace('#<(http://[^*]+)>#', '$1', $phpmailer->Body); // Convert line breaks & make links clickable $phpmailer->Body = make_clickable($phpmailer->Body); // Add header to message if found if (file_exists(get_stylesheet_directory() . "/email_header.html")) { $phpmailer->Body = file_get_contents(get_stylesheet_directory() . "/email_header.html") . "\n" . $phpmailer->Body; } elseif (file_exists(get_template_directory() . "/email_header.html")) { $phpmailer->Body = file_get_contents(get_template_directory() . "/email_header.html") . "\n" . $phpmailer->Body; } // Add footer to message if found if (file_exists(get_stylesheet_directory() . "/email_footer.html")) { $phpmailer->Body = $phpmailer->Body . "\n" . file_get_contents(get_stylesheet_directory() . "/email_footer.html"); } elseif (file_exists(get_template_directory() . "/email_footer.html")) { $phpmailer->Body = $phpmailer->Body . "\n" . file_get_contents(get_template_directory() . "/email_footer.html"); } // Replace variables in email global $current_user; $data = array("name" => $current_user->display_name, "sitename" => get_option("blogname"), "login_link" => pmpro_url("account"), "display_name" => $current_user->display_name, "user_email" => $current_user->user_email, "subject" => $phpmailer->Subject); foreach ($data as $key => $value) { $phpmailer->Body = str_replace("!!" . $key . "!!", $value, $phpmailer->Body); } do_action("pmpro_after_phpmailer_init", $phpmailer); do_action("pmpro_after_pmpmailer_init", $phpmailer); //typo left in for backwards compatibility }
function pmpron_manage_sites_preheader() { if (!is_admin()) { global $post, $current_user; if (!empty($post->post_content) && strpos($post->post_content, "[pmpron_manage_sites]") !== false) { /* Preheader operations here. */ //make sure they have site credits global $current_user; $credits = $current_user->pmpron_site_credits; if (empty($credits)) { //redirect to levels wp_redirect(pmpro_url("levels")); exit; } } } }
function pmpro_addon_packages_shortcode($atts, $content = null, $code = "") { // $atts ::= array of attributes // $content ::= text within enclosing form of shortcode element // $code ::= the shortcode found, when == callback name // examples: [pmpro_addon_packages show="none" include="subpages"] // table of addone packages that are subpages of the page with shortcode and showing no description excerpt global $wpdb, $post, $current_user; extract(shortcode_atts(array('checkout_button' => __('Buy Now', 'pmproap'), 'levels_button' => __('Choose a Level', 'pmproap'), 'exclude' => NULL, 'layout' => 'table', 'link' => true, 'include' => NULL, 'orderby' => 'menu_order', 'order' => 'ASC', 'thumbnail' => 'thumbnail', 'view_button' => __('View Now', 'pmproap')), $atts)); // prep exclude array $exclude = str_replace(" ", "", $exclude); $exclude = explode(",", $exclude); //turn 0's into falses if ($include == "subpages") { $post_type = "page"; $post_parent = $post->ID; } else { $post_type = array('post', 'page'); $post_parent = NULL; } if ($link === "0" || $link === "false" || $link === "no") { $link = false; } else { $link = true; } if ($thumbnail && strtolower($thumbnail) != "false") { if (strtolower($thumbnail) == "medium") { $thumbnail = "medium"; } elseif (strtolower($thumbnail) == "large") { $thumbnail = "large"; } else { $thumbnail = "thumbnail"; } } else { $thumbnail = false; } // get posts $args = array('meta_key' => '_pmproap_price', 'meta_compare' => '>', 'meta_value' => '0', "order" => $order, "orderby" => $orderby, 'posts_per_page' => -1, 'post_status' => 'publish', "post_type" => $post_type, "post_parent" => $post_parent, "post__not_in" => $exclude); $pmproap_posts = get_posts($args); $layout_cols = preg_replace('/[^0-9]/', '', $layout); if (!empty($layout_cols)) { $pmproap_posts_chunks = array_chunk($pmproap_posts, $layout_cols); } else { $pmproap_posts_chunks = array_chunk($pmproap_posts, 1); } ob_start(); if (!empty($pmproap_posts)) { ?> <style> .pmpro_addon_package td {vertical-align: middle; } tr.pmpro_addon_package td.pmpro_addon_package-title h3 {margin: 0; } #pmpro_addon_packages h3.pmpro_addon_package-title {margin: 0 0 2rem 0; } .pmpro_addon_package td.pmpro_addon_package-thumbnail img {max-width: 100%; height: auto; } .pmpro_addon_package td.pmpro_addon_package-buy .pmpro_btn, .pmpro_addon_package td.pmpro_addon_package-view .pmpro_btn {display: block; } </style> <?php if ($layout == 'table') { ?> <table id="pmpro_addon_packages" cellpadding="0" cellspacing="0" border="0"> <tbody> <?php foreach ($pmproap_posts as $post) { $pmproap_price = get_post_meta($post->ID, "_pmproap_price", true); ?> <tr id="pmpro_addon_package-<?php echo $post->ID; ?> " class="pmpro_addon_package"> <?php if (has_post_thumbnail() && !empty($thumbnail)) { ?> <td width="15%" class="pmpro_addon_package-thumbnail"> <?php if ($link) { echo '<a href="' . get_permalink() . '">' . get_the_post_thumbnail($post->ID, $thumbnail) . '</a>'; } else { echo get_the_post_thumbnail($post->ID, $thumbnail); } ?> </td> <?php } ?> <td class="pmpro_addon_package-title"> <h3> <?php if (!empty($link)) { echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>'; } else { echo get_the_title(); } ?> </h3> </td> <?php if (!empty($current_user->ID) && pmproap_hasAccess($current_user->ID, $post->ID)) { ?> <td width="25%" class="pmpro_addon_package-view"><a class="pmpro_btn" href="<?php echo the_permalink(); ?> "><?php echo $view_button; ?> </a></td> <?php } else { //which level to use for checkout link? $text_level_id = pmproap_getLevelIDForCheckoutLink($post->ID, $current_user->ID); ?> <td width="25%" class="pmpro_addon_package-buy"> <?php if (empty($text_level_id)) { ?> <a class="pmpro_btn" href="<?php echo pmpro_url("levels"); ?> "> <?php echo $levels_button; ?> </a> <?php } else { //what's the price $pmproap_price = get_post_meta($post->ID, "_pmproap_price", true); ?> <a class="pmpro_btn" href="<?php echo pmpro_url("checkout", "?level=" . $text_level_id . "&ap=" . $post->ID); ?> "> <?php echo $checkout_button; ?> — <span class="pmpro_addon_package-price"><?php echo pmpro_formatPrice($pmproap_price); ?> </span> </a> <?php } ?> </td> <?php } ?> </tr> <!-- end pmpro_addon_package--> <?php } ?> </tbody> </table> <!-- end #pmpro_addon_packages --> <?php } else { ?> <div id="pmpro_addon_packages"> <?php foreach ($pmproap_posts_chunks as $row) { ?> <div class="row"> <?php foreach ($row as $post) { $pmproap_price = get_post_meta($post->ID, "_pmproap_price", true); ?> <div class="medium-<?php if ($layout == '2col') { echo '6 '; } elseif ($layout == '3col') { echo '4 text-center '; } elseif ($layout == '4col') { echo '3 text-center '; } else { echo '12 '; } ?> columns"> <article id="pmpro_addon_package-<?php echo $post->ID; ?> " class="<?php echo implode(" ", get_post_class()); ?> pmpro_addon_package"> <header class="entry-header"><h3 class="entry-title pmpro_addon_package-title"> <?php if (has_post_thumbnail() && !empty($thumbnail)) { if ($layout == '3col' || $layout == '4col') { $thumbnail_class = "aligncenter"; } else { $thumbnail_class = "alignright"; } if ($link) { echo '<a href="' . get_permalink() . '">' . get_the_post_thumbnail($post->ID, $thumbnail, array('class' => $thumbnail_class)) . '</a>'; } else { echo get_the_post_thumbnail($post->ID, $thumbnail, array('class' => $thumbnail_class)); } } if (!empty($link)) { echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>'; } else { echo get_the_title(); } ?> </h3></header> <div class="entry-content"> <?php if (!empty($current_user->ID) && pmproap_hasAccess($current_user->ID, $post->ID)) { ?> <p class="pmpro_addon_package-view"><a class="pmpro_btn" href="<?php echo the_permalink(); ?> "><?php echo $view_button; ?> </a></p> <?php } else { //which level to use for checkout link? $text_level_id = pmproap_getLevelIDForCheckoutLink($post->ID, $current_user->ID); if (empty($text_level_id)) { ?> <p class="pmpro_addon_package-buy"><a class="pmpro_btn" href="<?php echo pmpro_url("levels"); ?> "><?php echo $levels_button; ?> </a></p> <?php } else { //what's the price $pmproap_price = get_post_meta($post->ID, "_pmproap_price", true); ?> <p class="pmpro_addon_package-buy"><a class="pmpro_btn" href="<?php echo pmpro_url("checkout", "?level=" . $text_level_id . "&ap=" . $post->ID); ?> "><?php echo $checkout_button; ?> — <span class="pmpro_addon_package-price"><?php echo pmpro_formatPrice($pmproap_price); ?> </span></a></p> <?php } } ?> </div> </article> <!-- end pmpro_addon_package--> </div> <?php } ?> </div> <!-- end row --> <?php if ($layout == '3col' || $layout == '4col') { echo "<hr />"; } ?> <?php } ?> </div> <!-- end #pmpro_addon_packages --> <?php } //Reset Query wp_reset_query(); } else { _e('No add on packages found.', 'pmproap'); } $temp_content = ob_get_contents(); ob_end_clean(); return $temp_content; }
function pmpro_getCheckoutButton($level_id, $button_text = NULL, $classes = NULL) { if (empty($button_text)) { $button_text = __("Sign Up for !!name!! Now", "pmpro"); } if (empty($classes)) { $classes = "pmpro_btn"; } if (empty($level_id)) { $r = __("Please specify a level id.", "pmpro"); } else { //get level $level = pmpro_getLevel($level_id); //replace vars $replacements = array("!!id!!" => $level->id, "!!name!!" => $level->name, "!!description!!" => $level->description, "!!confirmation!!" => $level->confirmation, "!!initial_payment!!" => $level->initial_payment, "!!billing_amount!!" => $level->billing_amount, "!!cycle_number!!" => $level->cycle_number, "!!cycle_period!!" => $level->cycle_period, "!!billing_limit!!" => $level->billing_limit, "!!trial_amount!!" => $level->trial_amount, "!!trial_limit!!" => $level->trial_limit, "!!expiration_number!!" => $level->expiration_number, "!!expiration_period!!" => $level->expiration_period); $button_text = str_replace(array_keys($replacements), $replacements, $button_text); //button text $r = "<a href=\"" . pmpro_url("checkout", "?level=" . $level_id) . "\" class=\"" . $classes . "\">" . $button_text . "</a>"; } return $r; }
<?php global $besecure; $besecure = false; global $current_user, $pmpro_msg, $pmpro_msgt, $pmpro_confirm, $pmpro_error; //if they don't have a membership, send them back to the subscription page if (empty($current_user->membership_level->ID)) { wp_redirect(pmpro_url("levels")); } if (isset($_REQUEST['confirm'])) { $pmpro_confirm = $_REQUEST['confirm']; } else { $pmpro_confirm = false; } if ($pmpro_confirm) { $old_level_id = $current_user->membership_level->id; $worked = pmpro_changeMembershipLevel(false, $current_user->ID); if ($worked === true && empty($pmpro_error)) { $pmpro_msg = __("Your membership has been cancelled.", 'pmpro'); $pmpro_msgt = "pmpro_success"; //send an email to the member $myemail = new PMProEmail(); $myemail->sendCancelEmail(); //send an email to the admin $myemail = new PMProEmail(); $myemail->sendCancelAdminEmail($current_user, $old_level_id); } else { global $pmpro_error; $pmpro_msg = $pmpro_error; $pmpro_msgt = "pmpro_error"; }
function pmprorh_email_passed($level) { global $wpdb, $pmpro_msg, $pmpro_msgt; //confirm email if (!empty($_GET['bemail']) && !is_user_logged_in()) { //make sure the email is available $oldemail = $wpdb->get_var("SELECT ID FROM {$wpdb->users} WHERE user_email = '" . esc_sql($_REQUEST['bemail']) . "' LIMIT 1"); if (!$oldemail || !apply_filters('pmpro_checkout_oldemail', true)) { //confirm email global $bemail, $bconfirmemail; $bemail = str_replace(" ", "+", $_REQUEST['bemail']); $bconfirmemail = $bemail; $_REQUEST['bconfirmemail'] = $_REQUEST['bemail']; //make sure bemail is still set later add_action("pmpro_checkout_after_password", "pmproh_pmpro_checkout_after_password"); //don't show the confirm email add_filter("pmpro_checkout_confirm_email", "pmproh_pmpro_checkout_confirm_email"); } else { //email is in use wp_redirect(home_url("/login/?redirect_to=" . pmpro_url("checkout", "?level=" . $_REQUEST['level']))); exit; } } return $level; }
function pmprosm_pmpro_email_body($body, $pmpro_email) { global $wpdb, $pmprosm_sponsored_account_levels; //only checkout emails, not admins if (strpos($pmpro_email->template, "checkout") !== false && strpos($pmpro_email->template, "admin") === false && strpos($pmpro_email->template, "debug") === false) { //get the user_id from the email $user_id = $wpdb->get_var("SELECT ID FROM {$wpdb->users} WHERE user_email = '" . $pmpro_email->data['user_email'] . "' LIMIT 1"); $level_id = $pmpro_email->data['membership_id']; $code_id = pmprosm_getCodeByUserID($user_id); if (!empty($user_id) && !empty($code_id) && pmprosm_isMainLevel($level_id)) { //get code $code = $wpdb->get_row("SELECT * FROM {$wpdb->pmpro_discount_codes} WHERE id = '" . esc_sql($code_id) . "' LIMIT 1"); //get sponsored levels $pmprosm_values = pmprosm_getValuesByMainLevel($level_id); if (!is_array($pmprosm_values['sponsored_level_id'])) { $sponsored_level_ids = array($pmprosm_values['sponsored_level_id']); } else { $sponsored_level_ids = $pmprosm_values['sponsored_level_id']; } //no sponsored levels to use codes for if (empty($sponsored_level_ids) || empty($sponsored_level_ids[0])) { return $body; } //no uses for this code if (empty($code->uses)) { return $body; } //check if we should update confirmation email if (isset($pmprosm_values['add_code_to_confirmation_email']) && $pmprosm_values['add_code_to_confirmation_email'] === false) { return $body; } //figure out urls for code $code_urls = array(); $pmpro_levels = pmpro_getAllLevels(true, true); foreach ($sponsored_level_ids as $sponsored_level_id) { $level_name = $pmpro_levels[$sponsored_level_id]->name; $code_urls[] = array("name" => $level_name, "url" => pmpro_url("checkout", "?level=" . $sponsored_level_id . "&discount_code=" . $code->code)); } //build message $message = "<p>" . sprintf(__("Give this code to your sponsored members to use at checkout: %s", "pmpro_sponsored_members"), $code->code) . "<br />"; if (count($code_urls) > 1) { $message .= __("Or provide one of these direct links to register:", "pmpro_sponsored_members") . "</p>"; } else { $message .= __("Or provide this direct link to register:", "pmpro_sponsored_members") . "</p>"; } $message .= "<ul>"; foreach ($code_urls as $code_url) { $message .= "<li>" . $code_url['name'] . ": <strong>" . $code_url['url'] . "</strong></li>"; } $message .= "</ul>"; $body = $message . "<hr />" . $body; } } return $body; }
function pmpro_shortcode_account($atts, $content = null, $code = "") { global $wpdb, $pmpro_msg, $pmpro_msgt, $pmpro_levels, $current_user, $levels; // $atts ::= array of attributes // $content ::= text within enclosing form of shortcode element // $code ::= the shortcode found, when == callback name // examples: [pmpro_account] [pmpro_account sections="membership,profile"/] extract(shortcode_atts(array('section' => '', 'sections' => 'membership,profile,invoices,links'), $atts)); //did they use 'section' instead of 'sections'? if (!empty($section)) { $sections = $section; } //turn into an array $sections = explode(',', $sections); ob_start(); //if a member is logged in, show them some info here (1. past invoices. 2. billing information with button to update.) if (pmpro_hasMembershipLevel()) { $ssorder = new MemberOrder(); $ssorder->getLastMemberOrder(); $invoices = $wpdb->get_results("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM {$wpdb->pmpro_membership_orders} WHERE user_id = '{$current_user->ID}' ORDER BY timestamp DESC LIMIT 6"); ?> <div id="pmpro_account"> <?php if (in_array('membership', $sections) || in_array('memberships', $sections)) { ?> <div id="pmpro_account-membership" class="pmpro_box"> <h3><?php _e("My Memberships", "pmpro"); ?> </h3> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th><?php _e("Level", "pmpro"); ?> </th> <th><?php _e("Billing", "pmpro"); ?> </th> <th><?php _e("Expiration", "pmpro"); ?> </th> </tr> </thead> <tbody> <?php //TODO: v2.0 will loop through levels here $level = $current_user->membership_level; ?> <tr> <td class="pmpro_account-membership-levelname"> <?php echo $current_user->membership_level->name; ?> <div class="pmpro_actionlinks"> <?php do_action("pmpro_member_action_links_before"); ?> <?php if (pmpro_isLevelExpiringSoon($current_user->membership_level)) { ?> <a href="<?php echo pmpro_url("checkout", "?level=" . $current_user->membership_level->id, "https"); ?> "><?php _e("Renew", "pmpro"); ?> </a> <?php } ?> <?php if (isset($ssorder->status) && $ssorder->status == "success" && (isset($ssorder->gateway) && in_array($ssorder->gateway, array("authorizenet", "paypal", "stripe", "braintree", "payflow", "cybersource")))) { ?> <a href="<?php echo pmpro_url("billing", "", "https"); ?> "><?php _e("Update Billing Info", "pmpro"); ?> </a> <?php } ?> <?php //To do: Only show CHANGE link if this level is in a group that has upgrade/downgrade rules if (count($pmpro_levels) > 1 && !defined("PMPRO_DEFAULT_LEVEL")) { ?> <a href="<?php echo pmpro_url("levels"); ?> "><?php _e("Change", "pmpro"); ?> </a> <?php } ?> <a href="<?php echo pmpro_url("cancel", "?level=" . $current_user->membership_level->id); ?> "><?php _e("Cancel", "pmpro"); ?> </a> <?php do_action("pmpro_member_action_links_after"); ?> </div> <!-- end pmpro_actionlinks --> </td> <td class="pmpro_account-membership-levelfee"> <p><?php echo pmpro_getLevelCost($level, true, true); ?> </p> </td> <td class="pmpro_account-membership-expiration"> <?php if ($current_user->membership_level->enddate) { echo date(get_option('date_format'), $current_user->membership_level->enddate); } else { echo "---"; } ?> </td> </tr> </tbody> </table> <?php //Todo: If there are multiple levels defined that aren't all in the same group defined as upgrades/downgrades ?> <div class="pmpro_actionlinks"> <a href="<?php echo pmpro_url("levels"); ?> "><?php _e("View all Membership Options", "pmpro"); ?> </a> </div> </div> <!-- end pmpro_account-membership --> <?php } ?> <?php if (in_array('profile', $sections)) { ?> <div id="pmpro_account-profile" class="pmpro_box"> <?php get_currentuserinfo(); ?> <h3><?php _e("My Account", "pmpro"); ?> </h3> <?php if ($current_user->user_firstname) { ?> <p><?php echo $current_user->user_firstname; ?> <?php echo $current_user->user_lastname; ?> </p> <?php } ?> <ul> <?php do_action('pmpro_account_bullets_top'); ?> <li><strong><?php _e("Username", "pmpro"); ?> :</strong> <?php echo $current_user->user_login; ?> </li> <li><strong><?php _e("Email", "pmpro"); ?> :</strong> <?php echo $current_user->user_email; ?> </li> <?php do_action('pmpro_account_bullets_bottom'); ?> </ul> <div class="pmpro_actionlinks"> <a href="<?php echo admin_url('profile.php'); ?> "><?php _e("Edit Profile", "pmpro"); ?> </a> <a href="<?php echo admin_url('profile.php'); ?> "><?php _e('Change Password', 'pmpro'); ?> </a> </div> </div> <!-- end pmpro_account-profile --> <?php } ?> <?php if (in_array('invoices', $sections) && !empty($invoices)) { ?> <div id="pmpro_account-invoices" class="pmpro_box"> <h3><?php _e("Past Invoices", "pmpro"); ?> </h3> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th><?php _e("Date", "pmpro"); ?> </th> <th><?php _e("Level", "pmpro"); ?> </th> <th><?php _e("Amount", "pmpro"); ?> </th> </tr> </thead> <tbody> <?php $count = 0; foreach ($invoices as $invoice) { if ($count++ > 4) { break; } //get an member order object $invoice_id = $invoice->id; $invoice = new MemberOrder(); $invoice->getMemberOrderByID($invoice_id); $invoice->getMembershipLevel(); ?> <tr id="pmpro_account-invoice-<?php echo $invoice->code; ?> "> <td><a href="<?php echo pmpro_url("invoice", "?invoice=" . $invoice->code); ?> "><?php echo date(get_option("date_format"), $invoice->timestamp); ?> </td> <td><?php echo $invoice->membership_level->name; ?> </td> <td><?php echo pmpro_formatPrice($invoice->total); ?> </td> </tr> <?php } ?> </tbody> </table> <?php if ($count == 6) { ?> <div class="pmpro_actionlinks"><a href="<?php echo pmpro_url("invoice"); ?> "><?php _e("View All Invoices", "pmpro"); ?> </a></div> <?php } ?> </div> <!-- end pmpro_account-invoices --> <?php } ?> <?php if (in_array('links', $sections) && (has_filter('pmpro_member_links_top') || has_filter('pmpro_member_links_bottom'))) { ?> <div id="pmpro_account-links" class="pmpro_box"> <h3><?php _e("Member Links", "pmpro"); ?> </h3> <ul> <?php do_action("pmpro_member_links_top"); ?> <?php do_action("pmpro_member_links_bottom"); ?> </ul> </div> <!-- end pmpro_account-links --> <?php } ?> </div> <!-- end pmpro_account --> <?php } $content = ob_get_contents(); ob_end_clean(); return $content; }
pmpro_twocheckoutExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id)); } // First Payment (checkout) (Will probably want to update order, but not send another email/etc) if ($message_type == 'ORDER_CREATED') { //initial payment, get the order $morder = new MemberOrder($order_id); $morder->getMembershipLevel(); $morder->getUser(); inslog("ORDER_CREATED: ORDER: " . var_export($morder, true) . "\n---\n"); //update membership if (pmpro_insChangeMembershipLevel($txn_id, $morder)) { inslog("Checkout processed (" . $morder->code . ") success!"); } else { inslog("ERROR: Couldn't change level for order (" . $morder->code . ")."); } pmpro_twocheckoutExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id)); } // Recurring Payment Success (recurring installment success and recurring is true) if ($message_type == 'RECURRING_INSTALLMENT_SUCCESS') { //is this a first payment? $last_subscr_order = new MemberOrder(); if ($last_subscr_order->getLastMemberOrderBySubscriptionTransactionID($txn_id) == false) { //first payment, get order $morder = new MemberOrder($order_id); $morder->getMembershipLevel(); $morder->getUser(); //update membership if (pmpro_insChangeMembershipLevel($txn_id, $morder)) { inslog("Checkout processed (" . $morder->code . ") success!"); } else { inslog("ERROR: Couldn't change level for order (" . $morder->code . ").");
//setup some values for the emails if (!empty($morder)) { $invoice = new MemberOrder($morder->id); } else { $invoice = NULL; } $current_user->membership_level = $pmpro_level; //make sure they have the right level info //send email to member $pmproemail = new PMProEmail(); $pmproemail->sendCheckoutEmail($current_user, $invoice); //send email to admin $pmproemail = new PMProEmail(); $pmproemail->sendCheckoutAdminEmail($current_user, $invoice); //redirect to confirmation $rurl = pmpro_url("confirmation", "?level=" . $pmpro_level->id); $rurl = apply_filters("pmpro_confirmation_url", $rurl, $user_id, $pmpro_level); wp_redirect($rurl); exit; } else { //uh oh. we charged them then the membership creation failed if (isset($morder) && $morder->cancel()) { $pmpro_msg = __("IMPORTANT: Something went wrong during membership creation. Your credit card authorized, but we cancelled the order immediately. You should not try to submit this form again. Please contact the site owner to fix this issue.", "pmpro"); $morder = NULL; } else { $pmpro_msg = __("IMPORTANT: Something went wrong during membership creation. Your credit card was charged, but we couldn't assign your membership. You should not submit this form again. Please contact the site owner to fix this issue.", "pmpro"); } } } } //default values
function sendMembershipExpiredEmail($user = NULL) { global $current_user, $wpdb; if(!$user) $user = $current_user; if(!$user) return false; $this->email = $user->user_email; $this->subject = "Your membership at " . get_option("blogname") . " has ended"; $this->template = "membership_expired"; $this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "siteemail" => get_bloginfo("admin_email"), "login_link" => wp_login_url(), "display_name" => $user->display_name, "user_email" => $user->user_email, "levels_link" => pmpro_url("levels")); return $this->sendEmail(); }
} else { $pmpro_msg = false; } //if no user, redirect to levels page if(empty($current_user->ID)) { $redirect = apply_filters("pmpro_account_preheader_no_user_redirect", pmpro_url("levels")); if($redirect) { wp_redirect($redirect); exit; } } //if no membership level, redirect to levels page if(empty($current_user->membership_level->ID)) { $redirect = apply_filters("pmpro_account_preheader_redirect", pmpro_url("levels")); if($redirect) { wp_redirect($redirect); exit; } } global $pmpro_levels; $pmpro_levels = pmpro_getAllLevels(); ?>
function pmprorh_signup_shortcode($atts, $content = null, $code = "") { // $atts ::= array of attributes // $content ::= text within enclosing form of shortcode element // $code ::= the shortcode found, when == callback name // examples: [pmpro_signup level="3" short="1" intro="0" button="Signup Now"] //make sure PMPro is activated if (!function_exists('pmpro_getLevel')) { return "Paid Memberships Pro must be installed to use the pmpro_signup shortcode."; } //default title if (!empty($level)) { $default_title = 'Register For ' . pmpro_getLevel($level)->name; } else { $default_title = 'Register For ' . get_option('blogname'); } //set defaults extract(shortcode_atts(array('button' => "Sign Up Now", 'intro' => "0", 'level' => NULL, 'login' => true, 'short' => NULL, 'title' => $default_title), $atts)); //turn 0's into falses if ($login === "0" || $login === "false" || $login === "no") { $login = false; } else { $login = true; } if ($short === "0" || $short === "false" || $short === "no") { $short = false; } else { $short = true; } if ($intro === "0" || $intro === "false" || $intro === "no") { $intro = false; } global $current_user, $membership_levels; ob_start(); ?> <?php if (!empty($current_user->ID) && pmpro_hasMembershipLevel($level, $current_user->ID)) { ?> <p>You are logged in as <?php echo $current_user->user_login; ?> .</p> <?php } else { ?> <form class="pmpro_form pmpro_signup_form" action="<?php echo pmpro_url("checkout"); ?> " method="post"> <h2><?php echo $title; ?> </h2> <?php if (!empty($intro)) { echo wpautop($intro); } ?> <input type="hidden" id="level" name="level" value="<?php echo $level; ?> " /> <?php if (!empty($current_user->ID)) { ?> <p id="pmpro_account_loggedin"> <?php printf(__('You are logged in as <strong>%s</strong>. If you would like to use a different account for this membership, <a href="%s">log out now</a>.', 'pmpro'), $current_user->user_login, wp_logout_url($_SERVER['REQUEST_URI'])); ?> </p> <?php } else { ?> <div> <label for="username">Username</label> <input id="username" name="username" type="text" class="input" size="30" value="" /> </div> <?php do_action("pmpro_checkout_after_username"); ?> <div> <label for="password">Password</label> <input id="password" name="password" type="password" class="input" size="30" value="" /> </div> <?php if ($short) { ?> <input type="hidden" name="password2_copy" value="1" /> <?php } else { ?> <div> <label for="password2">Confirm Password</label> <input id="password2" name="password2" type="password" class="input" size="30" value="" /> </div> <?php } ?> <?php do_action("pmpro_checkout_after_password"); ?> <div> <label for="bemail">E-mail Address</label> <input id="bemail" name="bemail" type="email" class="input" size="30" value="" /> </div> <?php if ($short) { ?> <input type="hidden" name="bconfirmemail_copy" value="1" /> <?php } else { ?> <div> <label for="bconfirmemail">Confirm E-mail</label> <input id="bconfirmemail" name="bconfirmemail" type="email" class="input" size="30" value="" /> </div> <?php } ?> <?php do_action("pmpro_checkout_after_email"); ?> <div class="pmpro_hidden"> <label for="fullname">Full Name</label> <input id="fullname" name="fullname" type="text" class="input" size="30" value="" /> <strong>LEAVE THIS BLANK</strong> </div> <div class="pmpro_captcha"> <?php global $recaptcha, $recaptcha_publickey; if ($recaptcha == 2 || !empty($level) && $recaptcha == 1 && pmpro_isLevelFree(pmpro_getLevel($level))) { echo pmpro_recaptcha_get_html($recaptcha_publickey, NULL, true); } ?> </div> <?php } ?> <div> <span id="pmpro_submit_span" > <input type="hidden" name="submit-checkout" value="1" /> <input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php echo $button; ?> " /> </span> </div> <?php if (!empty($login) && empty($current_user->ID)) { ?> <div style="text-align:center;"> <a href="<?php echo wp_login_url(get_permalink()); ?> "><?php _e('Log In', 'pmpro'); ?> </a> </div> <?php } ?> </form> <?php } ?> <?php $temp_content = ob_get_contents(); ob_end_clean(); return $temp_content; }
/** * Send billable invoice email. * * @since 1.8.6 * * @param WP_User $user * @param MemberOrder $order * * @return bool Whether the email was sent successfully. */ function sendBillableInvoiceEmail($user = NULL, $order = NULL) { global $current_user; if (!$user) { $user = $current_user; } if (!$user || !$order) { return false; } $level = pmpro_getLevel($order->membership_id); $this->email = $user->user_email; $this->subject = __('Invoice for Order #: ', 'pmpro') . $order->code; $this->template = "billable_invoice"; // Load invoice template if (file_exists(get_stylesheet_directory() . '/paid-memberships-pro/pages/orders-email.php')) { $template = get_stylesheet_directory() . '/paid-memberships-pro/pages/orders-email.php'; } elseif (file_exists(get_template_directory() . '/paid-memberships-pro/pages/orders-email.php')) { $template = get_template_directory() . '/paid-memberships-pro/pages/orders-email.php'; } else { $template = PMPRO_DIR . '/adminpages/templates/orders-email.php'; } ob_start(); require_once $template; $invoice = ob_get_contents(); ob_end_clean(); $this->data = array('order_code' => $order->code, 'login_link' => wp_login_url(pmpro_url("account")), 'invoice_link' => wp_login_url(pmpro_url("invoice", "?invoice=" . $order->code)), 'invoice' => $invoice); return $this->sendEmail(); }
<?php if (!$skip_account_fields && !$pmpro_review) { ?> <table id="pmpro_user_fields" class="pmpro_checkout" width="100%" cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th> <span class="pmpro_thead-name"><?php _e('Account Information', 'pmpro'); ?> </span> <span class="pmpro_thead-msg"><?php _e('Already have an account?', 'pmpro'); ?> <a href="<?php echo wp_login_url(pmpro_url("checkout", "?level=" . $pmpro_level->id)); ?> "><?php _e('Log in here', 'pmpro'); ?> </a></span> </th> </tr> </thead> <tbody> <tr> <td> <div> <label for="username"><?php _e('Username', 'pmpro'); ?>
function setExpressCheckout(&$order) { global $pmpro_currency; if(empty($order->code)) $order->code = $order->getRandomCode(); //clean up a couple values $order->payment_type = "PayPal Express"; $order->CardType = ""; $order->cardtype = ""; //taxes on initial amount $initial_payment = $order->InitialPayment; $initial_payment_tax = $order->getTaxForPrice($initial_payment); $initial_payment = round((float)$initial_payment + (float)$initial_payment_tax, 2); //taxes on the amount $amount = $order->PaymentAmount; $amount_tax = $order->getTaxForPrice($amount); $order->subtotal = $amount; $amount = round((float)$amount + (float)$amount_tax, 2); //paypal profile stuff $nvpStr = ""; $nvpStr .="&AMT=" . $initial_payment . "&CURRENCYCODE=" . $pmpro_currency . "&PROFILESTARTDATE=" . $order->ProfileStartDate; $nvpStr .= "&BILLINGPERIOD=" . $order->BillingPeriod . "&BILLINGFREQUENCY=" . $order->BillingFrequency . "&AUTOBILLAMT=AddToNextBilling"; $nvpStr .= "&DESC=" . urlencode(substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127)); $nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler"); $nvpStr .= "&NOSHIPPING=1&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . urlencode(substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127)) . "&L_PAYMENTTYPE0=Any"; //if billing cycles are defined if(!empty($order->TotalBillingCycles)) $nvpStr .= "&TOTALBILLINGCYCLES=" . $order->TotalBillingCycles; //if a trial period is defined if(!empty($order->TrialBillingPeriod)) { $trial_amount = $order->TrialAmount; $trial_tax = $order->getTaxForPrice($trial_amount); $trial_amount = round((float)$trial_amount + (float)$trial_tax, 2); $nvpStr .= "&TRIALBILLINGPERIOD=" . $order->TrialBillingPeriod . "&TRIALBILLINGFREQUENCY=" . $order->TrialBillingFrequency . "&TRIALAMT=" . $trial_amount; } if(!empty($order->TrialBillingCycles)) $nvpStr .= "&TRIALTOTALBILLINGCYCLES=" . $order->TrialBillingCycles; if(!empty($order->discount_code)) { $nvpStr .= "&ReturnUrl=" . urlencode(pmpro_url("checkout", "?level=" . $order->membership_level->id . "&discount_code=" . $order->discount_code . "&review=" . $order->code)); } else { $nvpStr .= "&ReturnUrl=" . urlencode(pmpro_url("checkout", "?level=" . $order->membership_level->id . "&review=" . $order->code)); } $additional_parameters = apply_filters("pmpro_paypal_express_return_url_parameters", array()); if(!empty($additional_parameters)) { foreach($additional_parameters as $key => $value) $nvpStr .= urlencode("&" . $key . "=" . $value); } $nvpStr .= "&CANCELURL=" . urlencode(pmpro_url("levels")); $this->httpParsedResponseAr = $this->PPHttpPost('SetExpressCheckout', $nvpStr); if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) { $order->status = "token"; $order->paypal_token = urldecode($this->httpParsedResponseAr['TOKEN']); $order->subscription_transaction_id = urldecode($this->httpParsedResponseAr['PROFILEID']); //update order $order->saveOrder(); //redirect to paypal $paypal_url = "https://www.paypal.com/webscr&cmd=_express-checkout&useraction=commit&token=" . $this->httpParsedResponseAr['TOKEN']; $environment = pmpro_getOption("gateway_environment"); if("sandbox" === $environment || "beta-sandbox" === $environment) { $paypal_url = "https://www.sandbox.paypal.com/webscr&useraction=commit&cmd=_express-checkout&token=" . $this->httpParsedResponseAr['TOKEN']; } wp_redirect($paypal_url); exit; //exit('SetExpressCheckout Completed Successfully: '.print_r($this->httpParsedResponseAr, true)); } else { $order->status = "error"; $order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0']; $order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']); $order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']); return false; //exit('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true)); } //write session? //redirect to PayPal }
<?php global $current_user; if ($current_user->ID) { $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID); } //is there a default level to redirect to? if (defined("PMPRO_DEFAULT_LEVEL")) { $default_level = intval(PMPRO_DEFAULT_LEVEL); } else { $default_level = false; } if ($default_level) { wp_redirect(pmpro_url("checkout", "?level=" . $default_level)); exit; } global $wpdb, $pmpro_msg, $pmpro_msgt; if (isset($_REQUEST['msg'])) { if ($_REQUEST['msg'] == 1) { $pmpro_msg = __('Your membership status has been updated - Thank you!', 'pmpro'); } else { $pmpro_msg = __('Sorry, your request could not be completed - please try again in a few moments.', 'pmpro'); $pmpro_msgt = "pmpro_error"; } } else { $pmpro_msg = false; } global $pmpro_levels; $pmpro_levels = pmpro_getAllLevels(false, true); $pmpro_levels = apply_filters("pmpro_levels_array", $pmpro_levels);
function pmpro_login_head() { $login_redirect = apply_filters("pmpro_login_redirect", true); if ((pmpro_is_login_page() || is_page("login") || class_exists("Theme_My_Login") && defined('Theme_My_Login::version') && version_compare(Theme_My_Login::version, "6.3") >= 0 && (Theme_My_Login::is_tml_page("register") || Theme_My_Login::is_tml_page("login"))) && $login_redirect) { //redirect registration page to levels page if (isset($_REQUEST['action']) && $_REQUEST['action'] == "register" || isset($_REQUEST['registration']) && $_REQUEST['registration'] == "disabled" || !is_admin() && class_exists("Theme_My_Login") && defined('Theme_My_Login::version') && version_compare(Theme_My_Login::version, "6.3") >= 0 && Theme_My_Login::is_tml_page("register")) { //redirect to levels page unless filter is set. $link = apply_filters("pmpro_register_redirect", pmpro_url("levels")); if (!empty($link)) { wp_redirect($link); exit; } else { return; } //don't redirect if pmpro_register_redirect filter returns false or a blank URL } //if theme my login is installed, redirect all logins to the login page if (pmpro_is_plugin_active("theme-my-login/theme-my-login.php")) { //check for the login page id and redirect there if we're not there already global $post; if (!empty($GLOBALS['theme_my_login']) && is_array($GLOBALS['theme_my_login']->options)) { //an older version of TML stores it this way if ($GLOBALS['theme_my_login']->options['page_id'] !== $post->ID) { //redirect to the real login page $link = get_permalink($GLOBALS['theme_my_login']->options['page_id']); if ($_SERVER['QUERY_STRING']) { $link .= "?" . $_SERVER['QUERY_STRING']; } wp_redirect($link); exit; } } elseif (!empty($GLOBALS['theme_my_login']->options)) { //another older version of TML stores it this way if ($GLOBALS['theme_my_login']->options->options['page_id'] !== $post->ID) { //redirect to the real login page $link = get_permalink($GLOBALS['theme_my_login']->options->options['page_id']); if ($_SERVER['QUERY_STRING']) { $link .= "?" . $_SERVER['QUERY_STRING']; } wp_redirect($link); exit; } } elseif (class_exists("Theme_My_Login") && defined('Theme_My_Login::version') && version_compare(Theme_My_Login::version, "6.3") >= 0) { //TML > 6.3 $link = Theme_My_Login::get_page_link("login"); if (!empty($link)) { //redirect if !is_page(), i.e. we're on wp-login.php if (!Theme_My_Login::is_tml_page()) { wp_redirect($link); exit; } } } //make sure users are only getting to the profile when logged in global $current_user; if (!empty($_REQUEST['action']) && $_REQUEST['action'] == "profile" && !$current_user->ID) { $link = get_permalink($GLOBALS['theme_my_login']->options->options['page_id']); wp_redirect($link); exit; } } } }
$pmproemail = new PMProEmail(); $pmproemail->sendBillingEmail($current_user, $morder); //send email to admin $pmproemail = new PMProEmail(); $pmproemail->sendBillingAdminEmail($current_user, $morder); } } else { $worked = true; } if ($worked) { //update the user meta too $meta_keys = array("pmpro_bfirstname", "pmpro_blastname", "pmpro_baddress1", "pmpro_baddress2", "pmpro_bcity", "pmpro_bstate", "pmpro_bzipcode", "pmpro_bphone", "pmpro_bemail", "pmpro_CardType", "pmpro_AccountNumber", "pmpro_ExpirationMonth", "pmpro_ExpirationYear"); $meta_values = array($bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bphone, $bemail, $CardType, hideCardNumber($AccountNumber), $ExpirationMonth, $ExpirationYear); pmpro_replaceUserMeta($current_user->ID, $meta_keys, $meta_values); //message $pmpro_msg = sprintf(__('Information updated. <a href="%s">« back to my account</a>', 'pmpro'), pmpro_url("account")); $pmpro_msgt = "pmpro_success"; } else { $pmpro_msg = $morder->error; if (!$pmpro_msg) { $pmpro_msg = __("Error updating billing information.", 'pmpro'); } $pmpro_msgt = "pmpro_error"; } } } else { //default values from DB $bfirstname = get_user_meta($current_user->ID, "pmpro_bfirstname", true); $blastname = get_user_meta($current_user->ID, "pmpro_blastname", true); $baddress1 = get_user_meta($current_user->ID, "pmpro_baddress1", true); $baddress2 = get_user_meta($current_user->ID, "pmpro_baddress2", true);
<?php $uses = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->pmpro_discount_codes_uses} WHERE code_id = '" . $code->id . "'"); if ($code->uses > 0) { echo "<strong>" . (int) $uses . "</strong>/" . $code->uses; } else { echo "<strong>" . (int) $uses . "</strong>/unlimited"; } ?> </td> <td> <?php $sqlQuery = "SELECT l.id, l.name FROM {$wpdb->pmpro_membership_levels} l LEFT JOIN {$wpdb->pmpro_discount_codes_levels} cl ON l.id = cl.level_id WHERE cl.code_id = '" . $code->id . "'"; $levels = $wpdb->get_results($sqlQuery); $level_names = array(); foreach ($levels as $level) { $level_names[] = "<a target=\"_blank\" href=\"" . pmpro_url("checkout", "?level=" . $level->id . "&discount_code=" . $code->code) . "\">" . $level->name . "</a>"; } if ($level_names) { echo implode(", ", $level_names); } else { echo "None"; } ?> </td> <?php do_action("pmpro_discountcodes_extra_cols_body", $code); ?> <td> <a href="?page=pmpro-discountcodes&edit=<?php echo $code->id; ?>
echo pmpro_url("cancel", "?levelstocancel=" . $level->id); ?> "><?php _e("Cancel", "pmpro"); ?> </a> </td> </tr> <?php } ?> </tbody> </table> <div class="pmpro_actionlinks"> <a href="<?php echo pmpro_url("cancel", "?levelstocancel=all"); ?> "><?php _e("Cancel All Memberships", "pmpro"); ?> </a> </div> <?php } } } else { ?> <p><a href="<?php echo get_home_url(); ?> "><?php
function pmproet_email_data($data, $email) { global $current_user, $pmpro_currency_symbol, $wpdb; if (!empty($data) && !empty($data['user_login'])) { $user = get_user_by('login', $data['user_login']); } if (empty($user)) { $user = $current_user; } $pmpro_user_meta = $wpdb->get_row("SELECT * FROM {$wpdb->pmpro_memberships_users} WHERE user_id = '" . $user->ID . "' AND status='active'"); //make sure data is an array if (!is_array($data)) { $data = array(); } //general data $new_data['sitename'] = get_option("blogname"); $new_data['siteemail'] = pmpro_getOption("from_email"); if (empty($new_data['login_link'])) { $new_data['login_link'] = wp_login_url(); } $new_data['levels_link'] = pmpro_url("levels"); //user data if (!empty($user)) { $new_data['name'] = $user->display_name; $new_data['user_login'] = $user->user_login; $new_data['display_name'] = $user->display_name; $new_data['user_email'] = $user->user_email; } //membership data if (!empty($user->membership_level)) { $new_data['enddate'] = date(get_option('date_format'), $user->membership_level->enddate); } //invoice data if (!empty($data['invoice_id'])) { $invoice = new MemberOrder($data['invoice_id']); if (!empty($invoice)) { $new_data['billing_name'] = $invoice->billing->name; $new_data['billing_street'] = $invoice->billing->street; $new_data['billing_city'] = $invoice->billing->city; $new_data['billing_state'] = $invoice->billing->state; $new_data['billing_zip'] = $invoice->billing->zip; $new_data['billing_country'] = $invoice->billing->country; $new_data['billing_phone'] = $invoice->billing->phone; $new_data['cardtype'] = $invoice->cardtype; $new_data['accountnumber'] = hideCardNumber($invoice->accountnumber); $new_data['expirationmonth'] = $invoice->expirationmonth; $new_data['expirationyear'] = $invoice->expirationyear; $new_data['instructions'] = wpautop(pmpro_getOption('instructions')); $new_data['invoice_id'] = $invoice->code; $new_data['invoice_total'] = $pmpro_currency_symbol . number_format($invoice->total, 2); $new_data['invoice_link'] = pmpro_url('invoice', '?invoice=' . $invoice->code); //billing address $new_data["billing_address"] = pmpro_formatAddress($invoice->billing->name, $invoice->billing->street, "", $invoice->billing->city, $invoice->billing->state, $invoice->billing->zip, $invoice->billing->country, $invoice->billing->phone); } } //membership change if (!empty($user->membership_level) && !empty($user->membership_level->ID)) { $new_data["membership_change"] = sprintf(__("The new level is %s.", "pmpro"), $user->membership_level->name); } else { $new_data["membership_change"] = __("Your membership has been cancelled", "pmpro"); } if (!empty($user->membership_level) && !empty($user->membership_level->enddate)) { $new_data["membership_change"] .= ". " . sprintf(__("This membership will expire on %s", "pmpro"), date(get_option('date_format'), $user->membership_level->enddate)); } elseif (!empty($email->expiration_changed)) { $new_data["membership_change"] .= ". " . __("This membership does not expire", "pmpro"); } //membership expiration $new_data['membership_expiration'] = ''; if (!empty($pmpro_user_meta->enddate)) { $new_data['membership_expiration'] = "<p>" . sprintf(__("This membership will expire on %s.", "pmpro"), $pmpro_user_meta->enddate . "</p>\n"); } //if others are used in the email look in usermeta $et_body = pmpro_getOption('email_' . $email->template . '_body'); $templates_in_email = preg_match_all("/!!([^!]+)!!/", $et_body, $matches); if (!empty($templates_in_email)) { $matches = $matches[1]; foreach ($matches as $match) { if (empty($new_data[$match])) { $usermeta = get_user_meta($user->ID, $match, true); if (!empty($usermeta)) { if (is_array($usermeta) && !empty($usermeta['fullurl'])) { $new_data[$match] = $usermeta['fullurl']; } elseif (is_array($usermeta)) { $new_data[$match] = implode(", ", $usermeta); } else { $new_data[$match] = $usermeta; } } } } } //now replace any new_data not already in data foreach ($new_data as $key => $value) { if (!isset($data[$key])) { $data[$key] = $value; } } return $data; }
</td> <td> <a href="?page=pmpro-affiliates&report=<?php echo $affiliate->id; ?> ">Report</a> <a href="?page=pmpro-affiliates&edit=<?php echo $affiliate->id; ?> ">Edit</a> <a href="?page=pmpro-affiliates&edit=-1©=<?php echo $affiliate->id; ?> ">Copy</a> <a target="_blank" href="<?php echo pmpro_url("levels", "?pa=" . $affiliate->code); ?> ">Link</a> </td> </tr> <?php } } ?> </tbody> </table> <?php } ?>
<?php } } ?> <nav id="nav-below" class="navigation" role="navigation"> <div class="nav-next alignright"> <a href="<?php echo pmpro_url("account"); ?> "><?php _e('View Your Membership Account →', 'pmpro'); ?> </a> </div> <?php if ($pmpro_invoice) { ?> <div class="nav-prev alignleft"> <a href="<?php echo pmpro_url("invoice"); ?> "><?php _e('← View All Invoices', 'pmpro'); ?> </a> </div> <?php } ?> </nav>
</thead> <tbody> <?php $i = 0; foreach ($invoices as $invoice) { ?> <tr class="<?php echo $i % 2 == 0 ? "even" : "odd"; ?> "> <td><?php echo date(get_option("date_format"), $invoice->timestamp); ?> </td> <td><a href="<?php echo pmpro_url("invoice", "?invoice=" . $invoice->code); ?> "><?php echo $invoice->code; ?> </a></td> <td><?php echo pmpro_formatPrice($invoice->total); ?> </td> </tr> <?php $i = $i + 1; } ?> </tbody>
_ex("Pending", "User without membership is in {pending} status.", "pmpro"); } ?> </li> </ul> <?php } ?> <nav id="nav-below" class="navigation" role="navigation"> <div class="nav-next alignright"> <?php if (!empty($current_user->membership_level)) { ?> <a href="<?php echo pmpro_url("account"); ?> "><?php _e('View Your Membership Account →', 'pmpro'); ?> </a> <?php } else { ?> <?php _e('If your account is not activated within a few minutes, please contact the site owner.', 'pmpro'); ?> <?php } ?> </div>
function pmpro_hide_pages_redirect() { global $post; if (!is_admin() && !empty($post->ID)) { if ($post->post_type == "attachment") { //check if the user has access to the parent if (!pmpro_has_membership_access($post->ID)) { wp_redirect(pmpro_url("levels")); exit; } } } }
function sendToPayPal(&$order) { global $pmpro_currency; //taxes on initial amount $initial_payment = $order->InitialPayment; $initial_payment_tax = $order->getTaxForPrice($initial_payment); $initial_payment = round((double) $initial_payment + (double) $initial_payment_tax, 2); //taxes on the amount $amount = $order->PaymentAmount; $amount_tax = $order->getTaxForPrice($amount); $amount = round((double) $amount + (double) $amount_tax, 2); //build PayPal Redirect $environment = pmpro_getOption("gateway_environment"); if ("sandbox" === $environment || "beta-sandbox" === $environment) { $paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?business=" . urlencode(pmpro_getOption("gateway_email")); } else { $paypal_url = "https://www.paypal.com/cgi-bin/webscr?business=" . urlencode(pmpro_getOption("gateway_email")); } if (pmpro_isLevelRecurring($order->membership_level)) { //convert billing period if ($order->BillingPeriod == "Day") { $period = "D"; } elseif ($order->BillingPeriod == "Week") { $period = "W"; } elseif ($order->BillingPeriod == "Month") { $period = "M"; } elseif ($order->BillingPeriod == "Year") { $period = "Y"; } else { $order->error = "Invalid billing period: " . $order->BillingPeriod; $order->shorterror = "Invalid billing period: " . $order->BillingPeriod; return false; } //other args $paypal_args = array('cmd' => '_xclick-subscriptions', 'a1' => number_format($initial_payment, 2), 'p1' => $order->BillingFrequency, 't1' => $period, 'a3' => number_format($amount, 2), 'p3' => $order->BillingFrequency, 't3' => $period, 'item_name' => substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127), 'email' => $order->Email, 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => $pmpro_currency, 'item_number' => $order->code, 'charset' => get_bloginfo('charset'), 'rm' => '2', 'return' => pmpro_url("confirmation", "?level=" . $order->membership_level->id), 'notify_url' => admin_url("admin-ajax.php") . "?action=ipnhandler", 'src' => '1', 'sra' => '1', 'bn' => PAYPAL_BN_CODE); //trial? /* Note here that the TrialBillingCycles value is being ignored. PayPal Standard only offers 1 payment during each trial period. */ if (!empty($order->TrialBillingPeriod)) { //if a1 and a2 are 0, let's just combine them. PayPal doesn't like a2 = 0. if ($paypal_args['a1'] == 0 && $order->TrialAmount == 0) { $paypal_args['p1'] = $paypal_args['p1'] + $order->TrialBillingFrequency; } else { $trial_amount = $order->TrialAmount; $trial_tax = $order->getTaxForPrice($trial_amount); $trial_amount = round((double) $trial_amount + (double) $trial_tax, 2); $paypal_args['a2'] = $trial_amount; $paypal_args['p2'] = $order->TrialBillingFrequency; $paypal_args['t2'] = $period; } } else { //we can try to work in any change in ProfileStartDate $psd = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0"; $adjusted_psd = apply_filters("pmpro_profile_start_date", $psd, $order); if ($psd != $adjusted_psd) { //someone is trying to push the start date back $adjusted_psd_time = strtotime($adjusted_psd, current_time("timestamp")); $seconds_til_psd = $adjusted_psd_time - current_time('timestamp'); $days_til_psd = floor($seconds_til_psd / (60 * 60 * 24)); //push back trial one by days_til_psd if ($days_til_psd > 90) { //we need to convert to weeks, because PayPal limits t1 to 90 days $weeks_til_psd = round($days_til_psd / 7); $paypal_args['p1'] = $weeks_til_psd; $paypal_args['t1'] = "W"; } elseif ($days_til_psd > 0) { //use days $paypal_args['p1'] = $days_til_psd; $paypal_args['t1'] = "D"; } } } //billing limit? if (!empty($order->TotalBillingCycles)) { if (!empty($trial_amount)) { $srt = intval($order->TotalBillingCycles) - 1; //subtract one for the trial period } else { $srt = intval($order->TotalBillingCycles); } //srt must be at least 2 or the subscription is not "recurring" according to paypal if ($srt > 1) { $paypal_args['srt'] = $srt; } else { $paypal_args['src'] = '0'; } } else { $paypal_args['srt'] = '0'; } //indefinite subscription } else { //other args $paypal_args = array('cmd' => '_xclick', 'amount' => number_format($initial_payment, 2), 'item_name' => substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127), 'email' => $order->Email, 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => $pmpro_currency, 'item_number' => $order->code, 'charset' => get_bloginfo('charset'), 'rm' => '2', 'return' => pmpro_url("confirmation", "?level=" . $order->membership_level->id), 'notify_url' => admin_url("admin-ajax.php") . "?action=ipnhandler", 'bn' => PAYPAL_BN_CODE); } $nvpStr = ""; foreach ($paypal_args as $key => $value) { $nvpStr .= "&" . $key . "=" . urlencode($value); } //anything modders might add $additional_parameters = apply_filters("pmpro_paypal_express_return_url_parameters", array()); if (!empty($additional_parameters)) { foreach ($additional_parameters as $key => $value) { $nvpStr .= urlencode("&" . $key . "=" . $value); } } $account_optional = apply_filters('pmpro_paypal_account_optional', true); if ($account_optional) { $nvpStr .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing'; } $nvpStr = apply_filters("pmpro_paypal_standard_nvpstr", $nvpStr, $order); //redirect to paypal $paypal_url .= $nvpStr; //wp_die(str_replace("&", "<br />", $paypal_url)); wp_redirect($paypal_url); exit; }
<?php } ?> <?php if (count($pmpro_levels) > 1 && !defined("PMPRO_DEFAULT_LEVEL")) { ?> <li><a href="<?php echo pmpro_url("levels"); ?> "><?php _e("Change Membership Level", "pmpro"); ?> </a></li> <?php } ?> <li><a href="<?php echo pmpro_url("cancel"); ?> "><?php _e("Cancel Membership", "pmpro"); ?> </a></li> <?php do_action("pmpro_member_links_bottom"); ?> </ul> </div> <!-- end pmpro_account-links --> </div> <!-- end pmpro_account --> <?php }