function pmpro_getLevelCost(&$level, $tags = true, $short = false) { //initial payment if (!$short) { $r = sprintf(__('The price for membership is <strong>%s</strong> now', 'pmpro'), pmpro_formatPrice($level->initial_payment)); } else { $r = sprintf(__('<strong>%s</strong> now', 'pmpro'), pmpro_formatPrice($level->initial_payment)); } //recurring part if ($level->billing_amount != '0.00') { if ($level->billing_limit > 1) { if ($level->cycle_number == '1') { $r .= sprintf(__(' and then <strong>%s per %s for %d more %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit)); } else { $r .= sprintf(__(' and then <strong>%s every %d %s for %d more %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit)); } } elseif ($level->billing_limit == 1) { $r .= sprintf(__(' and then <strong>%s after %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number)); } else { if ($level->billing_amount === $level->initial_payment) { if ($level->cycle_number == '1') { if (!$short) { $r = sprintf(__('The price for membership is <strong>%s per %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), pmpro_translate_billing_period($level->cycle_period)); } else { $r = sprintf(__('<strong>%s per %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), pmpro_translate_billing_period($level->cycle_period)); } } else { if (!$short) { $r = sprintf(__('The price for membership is <strong>%s every %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number)); } else { $r = sprintf(__('<strong>%s every %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number)); } } } else { if ($level->cycle_number == '1') { $r .= sprintf(__(' and then <strong>%s per %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period)); } else { $r .= sprintf(__(' and then <strong>%s every %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number)); } } } } else { $r .= '.'; } //add a space $r .= ' '; //trial part if ($level->trial_limit) { if ($level->trial_amount == '0.00') { if ($level->trial_limit == '1') { $r .= ' ' . __('After your initial payment, your first payment is Free.', 'pmpro'); } else { $r .= ' ' . sprintf(__('After your initial payment, your first %d payments are Free.', 'pmpro'), $level->trial_limit); } } else { if ($level->trial_limit == '1') { $r .= ' ' . sprintf(__('After your initial payment, your first payment will cost %s.', 'pmpro'), pmpro_formatPrice($level->trial_amount)); } else { $r .= ' ' . sprintf(__('After your initial payment, your first %d payments will cost %s.', 'pmpro'), $level->trial_limit, pmpro_formatPrice($level->trial_amount)); } } } //taxes part $tax_state = pmpro_getOption("tax_state"); $tax_rate = pmpro_getOption("tax_rate"); if ($tax_state && $tax_rate && !pmpro_isLevelFree($level)) { $r .= sprintf(__('Customers in %s will be charged %s%% tax.', 'pmpro'), $tax_state, round($tax_rate * 100, 2)); } if (!$tags) { $r = strip_tags($r); } $r = apply_filters("pmpro_level_cost_text", $r, $level, $tags, $short); //passing $tags and $short since v2.0 return $r; }
} } //no errors yet if ($pmpro_msgt != "pmpro_error") { //save user fields for PayPal Express if ($gateway == "paypalexpress") { if (!$current_user->ID) { $_SESSION['pmpro_signup_username'] = $username; $_SESSION['pmpro_signup_password'] = $password; $_SESSION['pmpro_signup_email'] = $bemail; } //can use this hook to save some other variables to the session do_action("pmpro_paypalexpress_session_vars"); } //special check here now for the "check" gateway if ($pmpro_requirebilling || $gateway == "check" && !pmpro_isLevelFree($pmpro_level)) { $morder = new MemberOrder(); $morder->membership_id = $pmpro_level->id; $morder->membership_name = $pmpro_level->name; $morder->discount_code = $discount_code; $morder->InitialPayment = $pmpro_level->initial_payment; $morder->PaymentAmount = $pmpro_level->billing_amount; $morder->ProfileStartDate = date("Y-m-d") . "T0:0:0"; $morder->BillingPeriod = $pmpro_level->cycle_period; $morder->BillingFrequency = $pmpro_level->cycle_number; if ($pmpro_level->billing_limit) { $morder->TotalBillingCycles = $pmpro_level->billing_limit; } if (pmpro_isLevelTrial($pmpro_level)) { $morder->TrialBillingPeriod = $pmpro_level->cycle_period; $morder->TrialBillingFrequency = $pmpro_level->cycle_number;
} else { jQuery('#discount_code_message').html(responseHTML); } //enable invite button jQuery('#discount_code_button').removeAttr('disabled'); } }); } }); </script> <?php if ($gateway == "check" && !pmpro_isLevelFree($pmpro_level)) { $instructions = pmpro_getOption("instructions"); echo '<div class="pmpro_check_instructions">' . wpautop($instructions) . '</div>'; } ?> <?php if ($tospage && !$pmpro_review) { ?> <table id="pmpro_tos_fields" class="pmpro_checkout top1em" width="100%" cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th><?php echo $tospage->post_title; ?> </th>
function pmprosm_pmpro_checkout_boxes() { global $current_user, $pmpro_level, $pmpro_currency_symbol; //only for PMPROSM_MAIN_ACCOUNT_LEVEL if (empty($pmpro_level) || !pmprosm_isMainLevel($pmpro_level->id)) { return; } //make sure options are defined for this $pmprosm_values = pmprosm_getValuesByMainLevel($pmpro_level->id); if (empty($pmprosm_values['max_seats']) || !isset($pmprosm_values['seat_cost'])) { return; } //get seats from submit if (isset($_REQUEST['seats'])) { $seats = intval($_REQUEST['seats']); } elseif (!empty($current_user->ID)) { $seats = get_user_meta($current_user->ID, "pmprosm_seats", true); } else { $seats = ""; } ?> <table id="pmpro_extra_seats" class="pmpro_checkout top1em" width="100%" cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th><?php _e("Would you like to purchase extra seats?", "pmpro_sponsored_members"); ?> </th> </tr> </thead> <tbody> <tr> <td> <div> <label for="seats"><?php echo __("How many?", "pmpro_sponsored_members"); ?> </label> <input type="text" id="seats" name="seats" value="<?php echo esc_attr($seats); ?> " size="10" /> <small> <?php //min seats defaults to 1 if (!empty($pmprosm_values['min_seats'])) { $min_seats = $pmprosm_values['min_seats']; } else { $min_seats = 1; } if (isset($pmprosm_values['seat_cost_text'])) { printf(__("Enter a number from %d to %d. %s", "pmpro_sponsored_members"), $min_seats, $pmprosm_values['max_seats'], $pmprosm_values['seat_cost_text']); } else { printf(__("Enter a number from %d to %d. +%s per extra seat.", "pmpro_sponsored_members"), $min_seats, $pmprosm_values['max_seats'], $pmpro_currency_symbol . $pmprosm_values['seat_cost']); } ?> </small> <?php //adding sub accounts at checkout? if (!empty($pmprosm_values['sponsored_accounts_at_checkout'])) { //look for existing sponsored accounts $children = pmprosm_getChildren($current_user->ID); if (!empty($children)) { echo "<hr />"; //get checkbox values if there if (isset($_REQUEST['old_sub_accounts_active'])) { $old_sub_accounts_active = $_REQUEST['old_sub_accounts_active']; } else { $old_sub_accounts_active = array(); } $i = 0; foreach ($children as $child_id) { ?> <div> <?php //get user $child = get_userdata($child_id); //acive? if (pmpro_hasMembershipLevel(NULL, $child_id)) { $active = true; } else { $active = false; } //checked? if (isset($old_sub_accounts_active[$i])) { $checked = $old_sub_accounts_active[$i]; } else { $checked = $active; } ?> <label><?php echo $child->display_name; ?> </label> <input type="checkbox" id="old_sub_accounts_active_<?php echo $i; ?> " class="old_sub_accounts_active" name="old_sub_accounts_active[]" value="<?php echo $child_id; ?> " <?php checked($checked, true); ?> /> <label class="pmpro_normal pmpro_clickable" for="old_sub_accounts_active_<?php echo $i; ?> "> <?php if (!empty($active)) { ?> <?php _e('Keep checked to keep this account active.', 'pmprosm'); ?> <?php } else { ?> <?php _e('Check to reactivate this account.', 'pmprosm'); ?> <?php } ?> </label> </div> <?php $i++; } } //end existing sponsored accounts echo "<div id = 'sponsored_accounts'>"; if (!empty($_REQUEST['add_sub_accounts_username'])) { $child_usernames = $_REQUEST['add_sub_accounts_username']; } elseif ($seats) { $child_usernames = array_fill(0, $seats, ''); } else { $child_usernames = array(); } if (!empty($_REQUEST['add_sub_accounts_first_name'])) { $child_first_names = $_REQUEST['add_sub_accounts_first_name']; } elseif ($seats) { $child_first_names = array_fill(0, $seats, ''); } else { $child_first_names = array(); } if (!empty($_REQUEST['add_sub_accounts_last_name'])) { $child_last_names = $_REQUEST['add_sub_accounts_last_name']; } elseif ($seats) { $child_last_names = array_fill(0, $seats, ''); } else { $child_last_names = array(); } if (!empty($_REQUEST['add_sub_accounts_email'])) { $child_emails = $_REQUEST['add_sub_accounts_email']; } elseif ($seats) { $child_emails = array_fill(0, $seats, ''); } else { $child_emails = array(); } for ($i = 0; $i < count($child_usernames); $i++) { if (is_array($child_usernames)) { $child_username = $child_usernames[$i]; } else { $child_username = ""; } if (is_array($child_usernames)) { $child_first_name = $child_first_names[$i]; } else { $child_first_name = ""; } if (is_array($child_usernames)) { $child_last_name = $child_last_names[$i]; } else { $child_last_name = ""; } if (is_array($child_usernames)) { $child_email = $child_emails[$i]; } else { $child_email = ""; } ?> <div id="sponsored_account_<?php echo $i; ?> "> <hr /> <?php if (!empty($pmprosm_values['children_get_name'])) { ?> <label><?php echo __("First Name", "pmpro_sponsored_members"); ?> </label> <input type="text" name="add_sub_accounts_first_name[]" value="<?php echo esc_attr($child_first_name); ?> " size="20" /> <br> <label><?php echo __("Last Name", "pmpro_sponsored_members"); ?> </label> <input type="text" name="add_sub_accounts_last_name[]" value="<?php echo esc_attr($child_last_name); ?> " size="20" /> <br> <?php } ?> <?php if (empty($pmprosm_values['children_hide_username'])) { ?> <label><?php echo __("Username", "pmpro_sponsored_members"); ?> </label> <input type="text" name="add_sub_accounts_username[]" value="<?php echo esc_attr($child_username); ?> " size="20" /> <br> <?php } ?> <?php if (empty($pmprosm_values['children_hide_email'])) { ?> <label><?php echo __("Email", "pmpro_sponsored_members"); ?> </label> <input type="text" name="add_sub_accounts_email[]" value="<?php echo esc_attr($child_email); ?> " size="20" /> <br> <?php } ?> <?php if (empty($pmprosm_values['children_hide_password'])) { ?> <label><?php echo __("Password", "pmpro_sponsored_members"); ?> </label> <input type="password" name="add_sub_accounts_password[]" value="" size="20" /> <?php } ?> <?php do_action('pmprosm_children_fields', $i, $seats); ?> </div> <?php } echo "</div>"; /* Get the HTML for the empty extra fields and save it to a variable. */ ob_start(); do_action("pmprosm_children_fields", false, $seats); $empty_child_fields = ob_get_contents(); ob_end_clean(); //also clean it up a bit $empty_child_fields = str_replace("\n", "", $empty_child_fields); } //if(!empty($pmprosm_values['sponsored_accounts_at_checkout'])) ?> <script> jQuery(document).ready(function() { var pmpro_base_level_is_free = <?php if (pmpro_isLevelFree($pmpro_level)) { echo "true"; } else { echo "false"; } ?> ; var seat_cost = <?php echo intval($pmprosm_values['seat_cost']); ?> ; var min_seats = <?php if (!empty($pmprosm_values['min_seats'])) { echo intval($pmprosm_values['min_seats']); } else { echo "0"; } ?> ; var max_seats = <?php if (!empty($pmprosm_values['max_seats'])) { echo intval($pmprosm_values['max_seats']); } else { echo "false"; } ?> ; //update things when the # of seats changes jQuery('#seats, input.old_sub_accounts_active').bind("change", function() { seatsChanged(); }); //run it once on load too seatsChanged(); function seatsChanged() { //num seats entered seats = parseInt(jQuery('#seats').val()); //num of old seats checked old_sub_accounts_active = 0; jQuery("input.old_sub_accounts_active:checked").each(function(){ old_sub_accounts_active += 1; }); //max sure not over max if(max_seats && seats > max_seats) { seats = max_seats; jQuery('#seats').val(seats); } //and not under min if(min_seats && seats < min_seats) { seats = min_seats; jQuery('#seats').val(seats); } <?php //how many child seats are shown now (if sponsored_accounts_at_checkout is set) if (!empty($pmprosm_values['sponsored_accounts_at_checkout'])) { ?> if(jQuery('#sponsored_accounts')) { children = jQuery('#sponsored_accounts').children(); i = children.length-1; //how many should we show newseats = seats - old_sub_accounts_active; if(newseats < children.length) { while(i >= newseats) { jQuery(children[i]).remove(); i--; } } else if(newseats > children.length) { i = children.length; while (i < newseats) { jQuery('#sponsored_accounts').append('<div id = "sponsored_account_'+i+'"><hr /><?php if (!empty($pmprosm_values["children_get_name"])) { ?> <label>First Name</label><input type="text" name="add_sub_accounts_first_name[]" value="" size="20" /><br><label>Last Name</label><input type="text" name="add_sub_accounts_last_name[]" value="" size="20" /><br><?php } if (empty($pmprosm_values["children_hide_username"])) { ?> <label>Username</label><input type="text" name="add_sub_accounts_username[]" value="" size="20" /><br><?php } ?> <label>Email</label><input type="text" name="add_sub_accounts_email[]" value"" size="20" /><br><label>Password</label><input type="password" name="add_sub_accounts_password[]" value="" size="20" /><?php echo $empty_child_fields; ?> </div>'); i++; } } } <?php } ?> if(pmpro_base_level_is_free && seat_cost && seats) { //need to show billing fields jQuery('#pmpro_payment_method').show(); jQuery('#pmpro_billing_address_fields').show(); jQuery('#pmpro_payment_information_fields').show(); } else if(pmpro_base_level_is_free) { //need to hide billing fields jQuery('#pmpro_payment_method').hide(); jQuery('#pmpro_billing_address_fields').hide(); jQuery('#pmpro_payment_information_fields').hide(); } <?php do_action('pmprosm_seats_changed_js'); ?> } }); </script> </div> </td> </tr> </tbody> </table> <?php }
_e('Full Name', 'pmpro'); ?> </label> <input id="fullname" name="fullname" type="text" class="input <?php echo pmpro_getClassForField("fullname"); ?> " size="30" value="" /> <strong><?php _e('LEAVE THIS BLANK', 'pmpro'); ?> </strong> </div> <div class="pmpro_captcha"> <?php global $recaptcha, $recaptcha_publickey; if ($recaptcha == 2 || $recaptcha == 1 && pmpro_isLevelFree($pmpro_level)) { echo recaptcha_get_html($recaptcha_publickey, NULL, true); } ?> </div> <?php do_action('pmpro_checkout_after_captcha'); ?> </td> </tr> </tbody> </table> <?php
?> odd<?php } if ($current_level == $level) { ?> active<?php } ?> "> <td><?php echo $current_level ? "<strong>{$level->name}</strong>" : $level->name; ?> </td> <td> <?php if (pmpro_isLevelFree($level)) { $cost_text = "<strong>" . __("Free", "pmpro") . "</strong>"; } else { $cost_text = pmpro_getLevelCost($level, true, true); } $expiration_text = pmpro_getLevelExpiration($level); if (!empty($cost_text) && !empty($expiration_text)) { echo $cost_text . "<br />" . $expiration_text; } elseif (!empty($cost_text)) { echo $cost_text; } elseif (!empty($expiration_text)) { echo $expiration_text; } ?> </td> <td>
function pmpropbc_pmpro_checkout_after_payment_information_fields() { global $gateway, $pmpro_level; $options = pmpropbc_getOptions($pmpro_level->id); if (!empty($options) && $options['setting'] > 0 && !pmpro_isLevelFree($pmpro_level)) { $instructions = pmpro_getOption("instructions"); if ($gateway != 'check') { $hidden = 'style="display:none;"'; } else { $hidden = ''; } echo '<div class="pmpro_check_instructions" ' . $hidden . '>' . wpautop($instructions) . '</div>'; } }
function sendCheckoutAdminEmail($user = NULL, $invoice = NULL) { global $wpdb, $current_user, $pmpro_currency_symbol; if(!$user) $user = $current_user; if(!$user) return false; //check settings $send = pmpro_getOption("email_admin_checkout"); if(empty($send)) return true; //didn't send, but we also don't want to indicate failure because the settings say to not send $this->email = get_bloginfo("admin_email"); $this->subject = "Member Checkout for " . $user->membership_level->name . " at " . get_option("blogname"); $this->data = array( "subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"), "membership_level_name" => $user->membership_level->name, "membership_cost" => pmpro_getLevelCost($user->membership_level), "login_link" => pmpro_url("account"), "display_name" => $user->display_name, "user_email" => $user->user_email,0 ); if($invoice) { if($invoice->gateway == "paypalexpress") $this->template = "checkout_express_admin"; elseif($invoice->gateway == "check") $this->template = "checkout_check_admin"; elseif(pmpro_isLevelTrial($user->membership_level)) $this->template = "checkout_trial_admin"; else $this->template = "checkout_paid_admin"; $this->data["invoice_id"] = $invoice->code; $this->data["invoice_total"] = $pmpro_currency_symbol . number_format($invoice->total, 2); $this->data["invoice_date"] = date(get_option('date_format'), $invoice->timestamp); $this->data["billing_name"] = $invoice->billing->name; $this->data["billing_street"] = $invoice->billing->street; $this->data["billing_city"] = $invoice->billing->city; $this->data["billing_state"] = $invoice->billing->state; $this->data["billing_zip"] = $invoice->billing->zip; $this->data["billing_country"] = $invoice->billing->country; $this->data["billing_phone"] = $invoice->billing->phone; $this->data["cardtype"] = $invoice->cardtype; $this->data["accountnumber"] = hideCardNumber($invoice->accountnumber); $this->data["expirationmonth"] = $invoice->expirationmonth; $this->data["expirationyear"] = $invoice->expirationyear; if($invoice->getDiscountCode()) $this->data["discount_code"] = "<p>Discount Code: " . $invoice->discount_code->code . "</p>\n"; else $this->data["discount_code"] = ""; } elseif(pmpro_isLevelFree($user->membership_level)) { $this->template = "checkout_free_admin"; global $discount_code; if(!empty($discount_code)) $this->data["discount_code"] = "<p>Discount Code: " . $discount_code . "</p>\n"; else $this->data["discount_code"] = ""; } else { $this->template = "checkout_freetrial_admin"; $this->data["discount_code"] = ""; } $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1"); if($enddate) $this->data["membership_expiration"] = "<p>This membership will expire on " . date(get_option('date_format'), $enddate) . ".</p>\n"; else $this->data["membership_expiration"] = ""; return $this->sendEmail(); }
function memberlitesc_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" submit_button="Signup Now"] extract(shortcode_atts(array('level' => NULL, 'title' => NULL, 'short' => NULL, 'intro' => NULL, 'submit_button' => "Sign Up Now"), $atts)); //turn 0's into falses if ($short == "0" || $short == "false" || $short == "no") { $short = false; } if (empty($title)) { $title = pmpro_getLevel($level)->name; } global $current_user, $membership_levels; ob_start(); ?> <?php if (empty($current_user->ID) || !pmpro_hasMembershipLevel($level, $current_user->ID)) { ?> <form class="pmpro_form memberlite_signup" action="<?php echo pmpro_url("checkout", "?level=" . $level, "https"); ?> " 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 || $recaptcha == 1 && pmpro_isLevelFree($pmpro_level)) { echo 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 $submit_button; ?> " /> </span> </div> </form> <?php } ?> <?php $temp_content = ob_get_contents(); ob_end_clean(); return $temp_content; }
function pmprodon_pmpro_checkout_after_level_cost() { global $pmpro_currency_symbol, $pmpro_level, $gateway, $pmpro_review; //get variable pricing info $donfields = get_option("pmprodon_" . $pmpro_level->id); //no variable pricing? just return if (empty($donfields) || empty($donfields['donations'])) { return; } //okay, now we're showing the form $min_price = $donfields['min_price']; $max_price = $donfields['max_price']; $dropdown_prices = $donfields['dropdown_prices']; if (isset($_REQUEST['donation'])) { $donation = preg_replace("[^0-9\\.]", "", $_REQUEST['donation']); } elseif (isset($_SESSION['donation'])) { $donation = preg_replace("[^0-9\\.]", "", $_SESSION['donation']); } elseif (!empty($min_price)) { $donation = $min_price; } else { $donation = ""; } ?> <p> Make a Gift <?php //check for dropdown if (!empty($dropdown_prices)) { //turn into an array $dropdown_prices = str_replace(" ", "", $dropdown_prices); $dropdown_prices = explode(",", $dropdown_prices); //check for other option $pmprodon_allow_other = array_search("other", $dropdown_prices); if ($pmprodon_allow_other !== false) { unset($dropdown_prices[$pmprodon_allow_other]); $pmprodon_allow_other = true; } //show dropdown sort($dropdown_prices); ?> <select id="donation_dropdown" name="donation_dropdown" <?php if ($pmpro_review) { ?> disabled="disabled"<?php } ?> > <?php foreach ($dropdown_prices as $price) { ?> <option <?php selected($price, $donation); ?> value="<?php echo esc_attr($price); ?> "><?php echo pmpro_formatPrice((double) $price); ?> </option> <?php } ?> <option value="other" <?php selected(true, !empty($donation) && !in_array($donation, $dropdown_prices)); ?> >Other</option> </select> <?php } ?> <span id="pmprodon_donation_input" <?php if (!empty($pmprodon_allow_other) && $_REQUEST['donation_dropdown'] != 'other') { ?> style="display: none;"<?php } ?> > <?php echo $pmpro_currency_symbol; ?> <input type="text" id="donation" name="donation" size="10" value="<?php echo esc_attr($donation); ?> " <?php if ($pmpro_review) { ?> disabled="disabled"<?php } ?> /> <?php if ($pmpro_review) { ?> <input type="hidden" name="donation" value="<?php echo esc_attr($donation); ?> " /><?php } ?> </span> <br /> <?php if (empty($pmpro_review)) { if (!empty($donfields['text'])) { echo $donfields['text']; } elseif (!empty($donfields['min_price']) && empty($donfields['max_price'])) { ?> Enter an amount <?php echo $pmpro_currency_symbol . $donfields['min_price']; ?> or greater<?php } elseif (!empty($donfields['max_price']) && empty($donfields['min_price'])) { ?> Enter an amount <?php echo $pmpro_currency_symbol . $donfields['max_price']; ?> or less<?php } elseif (!empty($donfields['max_price']) && !empty($donfields['min_price'])) { ?> Enter an amount between <?php echo $pmpro_currency_symbol . $donfields['min_price']; ?> and <?php echo $pmpro_currency_symbol . $donfields['max_price']; } } ?> </p> <script> //some vars for keeping track of whether or not we show billing var pmpro_gateway_billing = <?php if (in_array($gateway, array("paypalexpress", "twocheckout")) !== false) { echo "false"; } else { echo "true"; } ?> ; var pmpro_pricing_billing = <?php if (!pmpro_isLevelFree($pmpro_level)) { echo "true"; } else { echo "false"; } ?> ; var pmpro_donation_billing = pmpro_pricing_billing; //this script will hide show billing fields based on the price set jQuery(document).ready(function() { //bind other field toggle to dropdown change jQuery('#donation_dropdown').change(function() { pmprodon_toggleOther(); }); //bind check to price field var pmprodon_price_timer; jQuery('#donation').bind('keyup change', function() { pmprodon_price_timer = setTimeout(pmprodon_checkForFree, 500); }); if(jQuery('input[name=gateway]')) { jQuery('input[name=gateway]').bind('click', function() { pmprodon_price_timer = setTimeout(pmprodon_checkForFree, 500); }); } //check when page loads too pmprodon_toggleOther(); pmprodon_checkForFree(); }); function pmprodon_toggleOther() { //make sure there is a dropdown to check if(!jQuery('#donation_dropdown').length) return; //get val var donation_dropdown = jQuery('#donation_dropdown').val(); if(donation_dropdown == 'other') jQuery('#pmprodon_donation_input').show(); else jQuery('#pmprodon_donation_input').hide(); } function pmprodon_checkForFree() { var donation = parseFloat(jQuery('#donation').val()); //does the gateway require billing? if(jQuery('input[name=gateway]').length) { var no_billing_gateways = ['paypalexpress', 'twocheckout', 'check', 'paypalstandard']; var gateway = jQuery('input[name=gateway]:checked').val(); if(no_billing_gateways.indexOf(gateway) > -1) pmpro_gateway_billing = false; else pmpro_gateway_billing = true; } //is there a donation? if(donation || pmpro_pricing_billing) pmpro_donation_billing = true; else pmpro_donation_billing = false; //figure out if we should show the billing fields if(pmpro_gateway_billing && pmpro_donation_billing) { jQuery('#pmpro_billing_address_fields').show(); jQuery('#pmpro_payment_information_fields').show(); pmpro_require_billing = true; } else { jQuery('#pmpro_billing_address_fields').hide(); jQuery('#pmpro_payment_information_fields').hide(); pmpro_require_billing = false; } } </script> <?php }
function pmpro_getLevelCost(&$level, $tags = true) { global $pmpro_currency_symbol; $r = ' The price for membership is <strong>' . $pmpro_currency_symbol . number_format($level->initial_payment, 2) . '</strong> now'; if($level->billing_amount != '0.00') { $r .= ' and then <strong>' . $pmpro_currency_symbol . $level->billing_amount; if($level->cycle_number == '1') { $r .= ' per '; } elseif($level->billing_limit == 1) { $r .= ' after ' . $level->cycle_number . ' '; } else { $r .= ' every ' . $level->cycle_number . ' '; } $r .= sornot($level->cycle_period,$level->cycle_number); if($level->billing_limit > 1) { $r .= ' for ' . $level->billing_limit . ' more ' . sornot("payment",$level->billing_limit) . '.'; } else $r .= '.'; $r .= '</strong>'; } else $r .= '.'; if($level->trial_limit) { $r .= ' After your initial payment, your first '; if($level->trial_amount == '0.00') { if($level->trial_limit == '1') { $r .= 'payment is Free.'; } else { $r .= $level->trial_limit . ' payments are Free.'; } } else { $r .= $level->trial_limit.' ' .sornot("payment", $level->trial_limit) . ' will cost ' . $pmpro_currency_symbol . $level->trial_amount . '.'; } } //taxes? $tax_state = pmpro_getOption("tax_state"); $tax_rate = pmpro_getOption("tax_rate"); if($tax_state && $tax_rate && !pmpro_isLevelFree($level)) { $r .= " Customers in " . $tax_state . " will be charged " . round($tax_rate * 100, 2) . "% tax."; } if(!$tags) $r = strip_tags($r); $r = apply_filters("pmpro_level_cost_text", $r, $level); return $r; }
/** * Show instructions on checkout page * Moved here from pages/checkout.php * @since 1.8.9.3 */ static function pmpro_checkout_after_payment_information_fields() { global $gateway; global $pmpro_level; if ($gateway == "check" && !pmpro_isLevelFree($pmpro_level)) { $instructions = pmpro_getOption("instructions"); echo '<div class="pmpro_check_instructions">' . wpautop($instructions) . '</div>'; } }
<?php $sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels "; if($s) $sqlQuery .= "WHERE name LIKE '%$s%' "; $sqlQuery .= "ORDER BY id ASC"; $levels = $wpdb->get_results($sqlQuery, OBJECT); foreach($levels as $level) { ?> <tr class="<?php if(!$level->allow_signups) { ?>pmpro_gray<?php } ?> <?php if(!pmpro_checkLevelForStripeCompatibility($level) || !pmpro_checkLevelForBraintreeCompatibility($level) || !pmpro_checkLevelForPayflowCompatibility($level)) { ?>pmpro_error<?php } ?>"> <td><?php echo $level->id?></td> <td><?php echo $level->name?></td> <td> <?php if(pmpro_isLevelFree($level)) { ?> FREE <?php } else { ?> <?php echo $pmpro_currency_symbol?><?php echo $level->initial_payment?> <?php } ?> </td> <td> <?php if(!pmpro_isLevelRecurring($level)) { ?> -- <?php } else { ?> <?php echo $pmpro_currency_symbol?><?php echo $level->billing_amount?> every <?php echo $level->cycle_number.' '.sornot($level->cycle_period,$level->cycle_number)?> <?php if($level->billing_limit) { ?>(for <?php echo $level->billing_limit?> <?php echo sornot($level->cycle_period,$level->billing_limit)?>)<?php } ?> <?php } ?> </td>
//hide/show billing if (pmpro_isLevelFree($code_level) || pmpro_getGateway() == "paypalexpress" || pmpro_getGateway() == "paypalstandard" || pmpro_getGateway() == 'check') { ?> jQuery('#pmpro_billing_address_fields').hide(); jQuery('#pmpro_payment_information_fields').hide(); <?php } else { ?> jQuery('#pmpro_billing_address_fields').show(); jQuery('#pmpro_payment_information_fields').show(); <?php } //hide/show paypal button if (pmpro_getGateway() == "paypalexpress" || pmpro_getGateway() == "paypalstandard") { if (pmpro_isLevelFree($code_level)) { ?> jQuery('#pmpro_paypalexpress_checkout').hide(); jQuery('#pmpro_submit_span').show(); <?php } else { ?> jQuery('#pmpro_submit_span').hide(); jQuery('#pmpro_paypalexpress_checkout').show(); <?php } } //filter to insert your own code do_action('pmpro_applydiscountcode_return_js', $discount_code, $discount_code_id, $level_id, $code_level);
function getLevels() { 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); if ($pmpro_msg) { ?> <div class="pmpro_message <?php echo $pmpro_msgt; ?> "><?php echo $pmpro_msg; ?> </div> <?php } ?> <div id="main" class="site-main clr"> <div id="membership-wrapper"> <?php $count = 0; $count_levels = count($pmpro_levels); $tmp = 0; foreach ($pmpro_levels as $level) { if (isset($current_user->membership_level->ID)) { $current_level = $current_user->membership_level->ID == $level->id; } else { $current_level = false; } ?> <?php $last = $count_levels - $tmp; ?> <?php $tmp = $tmp + 1; ?> <div class="box-level <?php if ($count++ % 2 == 0) { ?> odd<?php } else { ?> even<?php } if ($current_level == $level) { ?> active<?php } if ($last == 2 || $last == 1) { ?> last-box<?php } ?> "> <h1><?php echo $current_level ? "<strong>{$level->name}</strong>" : $level->name; ?> </h1> <div class="copy"> <?php if (pmpro_isLevelFree($level)) { $cost_text = "<strong>Free</strong>"; } else { $cost_text = pmpro_getLevelCost($level, true, true); } $expiration_text = pmpro_getLevelExpiration($level); if (!empty($cost_text) && !empty($expiration_text)) { echo $cost_text . "<br />" . $expiration_text; } elseif (!empty($cost_text)) { echo $cost_text; } elseif (!empty($expiration_text)) { echo $expiration_text; } ?> </div> <div class="links"> <?php if (empty($current_user->membership_level->ID)) { ?> <a class="pmpro_btn pmpro_btn-select sign-up" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php _e('Sign Up', 'pmpro'); ?> </a> <?php } elseif (!$current_level) { ?> <!-- <a class="pmpro_btn pmpro_btn-select" href="<?php //echo pmpro_url("checkout", "?level=" . $level->id, "https") ?> "><?php //_e('Change Subscription', 'pmpro'); ?> </a> --> <a class="pmpro_btn pmpro_btn-select change-subscription" href="<?php echo "/billing/subscription-checkout?level=" . $level->id; ?> "><?php _e('Change Subscription', 'pmpro'); ?> </a> <?php } elseif ($current_level) { ?> <?php //if it's a one-time-payment level, offer a link to renew if (!pmpro_isLevelRecurring($current_user->membership_level) && !empty($current_user->membership_level->enddate)) { ?> <a class="pmpro_btn pmpro_btn-select renew" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php _e('Renew', 'pmpro'); ?> </a> <?php } else { ?> <a class="pmpro_btn disabled your-current-level" href="<?php echo pmpro_url("account"); ?> "><?php _e('Your Current Level', 'pmpro'); ?> </a> <?php } ?> <?php } ?> </div> </div> <?php } ?> <div class="clear clearfix"></div> <nav id="nav-below" class="navigation" role="navigation"> <div class="nav-previous alignleft"> <?php if (!empty($current_user->membership_level->ID)) { ?> <!-- <a href="<?php echo pmpro_url("account"); ?> "><?php _e('← Return to Your Account', 'pmpro'); ?> </a> --> <?php } else { ?> <a href="<?php echo home_url(); ?> "><?php _e('← Return to Home', 'pmpro'); ?> </a> <?php } ?> </div> </nav> </div> </div> <?php }
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; }
function pmpro_getLevelCost(&$level, $tags = true) { global $pmpro_currency_symbol; //initial payment $r = sprintf(_x('The price for membership is <strong>%s</strong> now', 'Initial payment in cost text generation.', 'pmpro'), $pmpro_currency_symbol . number_format($level->initial_payment, 2)); //recurring part if ($level->billing_amount != '0.00') { if ($level->billing_limit > 1) { if ($level->cycle_number == '1') { $r .= sprintf(__(' and then <strong>%s per %s for %d more %s</strong>.', 'Recurring payment in cost text generation. E.g. $5 every month for 2 more payments.', 'pmpro'), $pmpro_currency_symbol . $level->billing_amount, pmpro_translate_billing_period($level->cycle_period), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit)); } else { $r .= sprintf(__(' and then <strong>%s every %d %s for %d more %s</strong>.', 'Recurring payment in cost text generation. E.g., $5 every 2 months for 2 more payments.', 'pmpro'), $pmpro_currency_symbol . $level->billing_amount, $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit)); } } elseif ($level->billing_limit == 1) { $r .= sprintf(__(' and then <strong>%s after %d %s</strong>.', 'Recurring payment in cost text generation. E.g. $5 after 2 months.', 'pmpro'), $pmpro_currency_symbol . $level->billing_amount, $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number)); } else { if ($level->cycle_number == '1') { $r .= sprintf(__(' and then <strong>%s per %s</strong>.', 'Recurring payment in cost text generation. E.g. $5 every month.', 'pmpro'), $pmpro_currency_symbol . $level->billing_amount, pmpro_translate_billing_period($level->cycle_period)); } else { $r .= sprintf(__(' and then <strong>%s every %d %s</strong>.', 'Recurring payment in cost text generation. E.g., $5 every 2 months.', 'pmpro'), $pmpro_currency_symbol . $level->billing_amount, $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number)); } } } else { $r .= '.'; } //trial part if ($level->trial_limit) { if ($level->trial_amount == '0.00') { if ($level->trial_limit == '1') { $r .= ' ' . _x('After your initial payment, your first payment is Free.', 'Trial payment in cost text generation.', 'pmpro'); } else { $r .= ' ' . sprintf(_x('After your initial payment, your first %d payments are Free.', 'Trial payment in cost text generation.', 'pmpro'), $level->trial_limit); } } else { if ($level->trial_limit == '1') { $r .= ' ' . sprintf(_x('After your initial payment, your first payment will cost %s.', 'Trial payment in cost text generation.', 'pmpro'), $pmpro_currency_symbol . $level->trial_amount); } else { $r .= ' ' . sprintf(_x('After your initial payment, your first %d payments will cost %s.', 'Trial payment in cost text generation. E.g. ... first 2 payments will cost $5', 'pmpro'), $level->trial_limit, $pmpro_currency_symbol . $level->trial_amount); } } } //taxes part $tax_state = pmpro_getOption("tax_state"); $tax_rate = pmpro_getOption("tax_rate"); if ($tax_state && $tax_rate && !pmpro_isLevelFree($level)) { $r .= sprintf(_x('Customers in %s will be charged %s%% tax.', 'Tax part in cost text generation', 'pmpro'), $tax_state, round($tax_rate * 100, 2)); } if (!$tags) { $r = strip_tags($r); } $r = apply_filters("pmpro_level_cost_text", $r, $level); return $r; }
$oldemail = apply_filters("pmpro_checkout_oldemail", $oldemail); } if (!empty($oldusername)) { pmpro_setMessage(__("That username is already taken. Please try another.", "pmpro"), "pmpro_error"); $pmpro_error_fields[] = "username"; } if (!empty($oldemail)) { pmpro_setMessage(__("That email address is already taken. Please try another.", "pmpro"), "pmpro_error"); $pmpro_error_fields[] = "bemail"; $pmpro_error_fields[] = "bconfirmemail"; } //only continue if there are no other errors yet if ($pmpro_msgt != "pmpro_error") { //check recaptcha first global $recaptcha; if (!$skip_account_fields && ($recaptcha == 2 || $recaptcha == 1 && pmpro_isLevelFree($pmpro_level))) { global $recaptcha_privatekey; if (isset($_POST["recaptcha_challenge_field"])) { //using older recaptcha lib $resp = recaptcha_check_answer($recaptcha_privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); $recaptcha_valid = $resp->is_valid; $recaptcha_errors = $resp->error; } else { //using newer recaptcha lib $reCaptcha = new pmpro_ReCaptcha($recaptcha_privatekey); $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]); $recaptcha_valid = $resp->success; $recaptcha_errors = $resp->errorCodes; } if (!$recaptcha_valid) { $pmpro_msg = sprintf(__("reCAPTCHA failed. (%s) Please try again.", "pmpro"), $recaptcha_errors);
<?php global $current_user, $pmpro_invoice; if ($current_user->ID) { $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID); } /* Use the filter to add your gateway here if you want to show them a message on the confirmation page while their checkout is pending. For example, when PayPal Standard is used, we need to wait for PayPal to send a message through IPN that the payment was accepted. In the meantime, the order is in pending status and the confirmation page shows a message RE waiting. */ $gateways_with_pending_status = apply_filters('pmpro_gateways_with_pending_status', array('paypalstandard', 'twocheckout', 'gourl')); //must be logged in if (empty($current_user->ID) || empty($current_user->membership_level->ID) && !in_array(pmpro_getGateway(), $gateways_with_pending_status)) { wp_redirect(home_url()); } //if membership is a paying one, get invoice from DB if (!empty($current_user->membership_level) && !pmpro_isLevelFree($current_user->membership_level)) { $pmpro_invoice = new MemberOrder(); $pmpro_invoice->getLastMemberOrder($current_user->ID, apply_filters("pmpro_confirmation_order_status", array("success", "pending"))); }
function pmpro_membership_level_profile_fields($user) { global $current_user; $membership_level_capability = apply_filters("pmpro_edit_member_capability", "manage_options"); if (!current_user_can($membership_level_capability)) { return false; } global $wpdb; /*$user->membership_level = $wpdb->get_row("SELECT l.id AS ID, l.name AS name FROM {$wpdb->pmpro_membership_levels} AS l JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id) WHERE mu.user_id = " . $user->ID . " LIMIT 1");*/ $user->membership_level = pmpro_getMembershipLevelForUser($user->ID); $levels = $wpdb->get_results("SELECT * FROM {$wpdb->pmpro_membership_levels}", OBJECT); if (!$levels) { return ""; } ?> <h3><?php _e("Membership Level", "pmpro"); ?> </h3> <table class="form-table"> <?php $show_membership_level = true; $show_membership_level = apply_filters("pmpro_profile_show_membership_level", $show_membership_level, $user); if ($show_membership_level) { ?> <tr> <th><label for="membership_level"><?php _e("Current Level", "pmpro"); ?> </label></th> <td> <select name="membership_level"> <option value="" <?php if (empty($user->membership_level->ID)) { ?> selected="selected"<?php } ?> >-- <?php _e("None", "pmpro"); ?> --</option> <?php foreach ($levels as $level) { ?> <option value="<?php echo $level->id; ?> " <?php selected($level->id, isset($user->membership_level->ID) ? $user->membership_level->ID : 0); ?> ><?php echo $level->name; ?> </option> <?php } ?> </select> <span id="current_level_cost"> <?php $membership_values = pmpro_getMembershipLevelForUser($user->ID); if (empty($membership_values) || pmpro_isLevelFree($membership_values)) { ?> <?php _e("Not paying.", "pmpro"); ?> <?php } else { //we tweak the initial payment here so the text here effectively shows the recurring amount $membership_values->initial_payment = $membership_values->billing_amount; echo pmpro_getLevelCost($membership_values, true, true); } ?> </span> <p id="cancel_description" class="description hidden"><?php _e("This will not change the subscription at the gateway unless the 'Cancel' checkbox is selected below.", "pmpro"); ?> </p> </td> </tr> <?php } $show_expiration = true; $show_expiration = apply_filters("pmpro_profile_show_expiration", $show_expiration, $user); if ($show_expiration) { //is there an end date? $user->membership_level = pmpro_getMembershipLevelForUser($user->ID); $end_date = !empty($user->membership_level->enddate); //some vars for the dates $current_day = date("j"); if ($end_date) { $selected_expires_day = date("j", $user->membership_level->enddate); } else { $selected_expires_day = $current_day; } $current_month = date("M"); if ($end_date) { $selected_expires_month = date("m", $user->membership_level->enddate); } else { $selected_expires_month = date("m"); } $current_year = date("Y"); if ($end_date) { $selected_expires_year = date("Y", $user->membership_level->enddate); } else { $selected_expires_year = (int) $current_year + 1; } ?> <tr> <th><label for="expiration"><?php _e("Expires", "pmpro"); ?> </label></th> <td> <select id="expires" name="expires"> <option value="0" <?php if (!$end_date) { ?> selected="selected"<?php } ?> ><?php _e("No", "pmpro"); ?> </option> <option value="1" <?php if ($end_date) { ?> selected="selected"<?php } ?> ><?php _e("Yes", "pmpro"); ?> </option> </select> <span id="expires_date" <?php if (!$end_date) { ?> style="display: none;"<?php } ?> > on <select name="expires_month"> <?php for ($i = 1; $i < 13; $i++) { ?> <option value="<?php echo $i; ?> " <?php if ($i == $selected_expires_month) { ?> selected="selected"<?php } ?> ><?php echo date("M", strtotime($i . "/1/" . $current_year, current_time("timestamp"))); ?> </option> <?php } ?> </select> <input name="expires_day" type="text" size="2" value="<?php echo $selected_expires_day; ?> " /> <input name="expires_year" type="text" size="4" value="<?php echo $selected_expires_year; ?> " /> </span> <script> jQuery('#expires').change(function() { if(jQuery(this).val() == 1) jQuery('#expires_date').show(); else jQuery('#expires_date').hide(); }); </script> </td> </tr> <tr class="more_level_options"> <th></th> <td> <label for="send_admin_change_email"><input value="1" id="send_admin_change_email" name="send_admin_change_email" type="checkbox"> Send the user an email about this change.</label> </td> </tr> <tr class="more_level_options"> <th></th> <td> <label for="cancel_subscription"><input value="1" id="cancel_subscription" name="cancel_subscription" type="checkbox"> Cancel this user's subscription at the gateway.</label> </td> </tr> <?php } ?> </table> <script> jQuery(document).ready(function() { //vars for fields var $membership_level_select = jQuery("[name=membership_level]"); var $expires_select = jQuery("[name=expires]"); var $expires_month_select = jQuery("[name=expires_month]"); var $expires_day_text = jQuery("[name=expires_day]"); var $expires_year_text = jQuery("[name=expires_year]"); //note old data to check for changes var old_level = $membership_level_select.val(); var old_expires = $expires_select.val(); var old_expires_month = $expires_month_select.val(); var old_expires_day = $expires_day_text.val(); var old_expires_year = $expires_year_text.val(); var current_level_cost = jQuery("#current_level_cost").text(); //hide by default jQuery(".more_level_options").hide(); function pmpro_checkForLevelChangeInProfile() { //cancelling sub or not if($membership_level_select.val() == 0) { jQuery("#cancel_subscription").attr('checked', true); jQuery("#current_level_cost").text("Not paying."); } else { jQuery("#cancel_subscription").attr('checked', false); jQuery("#current_level_cost").text(current_level_cost); } //did level or expiration change? if( $membership_level_select.val() != old_level || $expires_select.val() != old_expires || $expires_month_select.val() != old_expires_month || $expires_day_text.val() != old_expires_day || $expires_year_text.val() != old_expires_year ) { jQuery(".more_level_options").show(); jQuery("#cancel_description").show(); } else { jQuery(".more_level_options").hide(); jQuery("#cancel_description").hide(); } } //run check when fields change $membership_level_select.change(function() { pmpro_checkForLevelChangeInProfile(); }); $expires_select.change(function() { pmpro_checkForLevelChangeInProfile(); }); $expires_month_select.change(function() { pmpro_checkForLevelChangeInProfile(); }); $expires_day_text.change(function() { pmpro_checkForLevelChangeInProfile(); }); $expires_year_text.change(function() { pmpro_checkForLevelChangeInProfile(); }); jQuery("#cancel_subscription").change(function() { if(jQuery(this).attr('checked') == 'checked') { jQuery("#cancel_description").hide(); jQuery("#current_level_cost").text("Not paying."); } else { jQuery("#current_level_cost").text(current_level_cost); jQuery("#cancel_description").show(); } }); }); </script> <?php do_action("pmpro_after_membership_level_profile_fields", $user); }
function memberlite_levels_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: [memberlite_levels levels="1,2,3" layout="table" hightlight="2" description="false" checkout_button="Register Now"] extract(shortcode_atts(array('account_button' => 'Your Level', 'back_link' => '1', 'checkout_button' => 'Select', 'compare' => NULL, 'description' => '1', 'discount_code' => NULL, 'expiration' => '1', 'highlight' => NULL, 'layout' => 'div', 'levels' => NULL, 'more_button' => NULL, 'price' => 'short', 'renew_button' => 'Renew'), $atts)); global $wpdb, $pmpro_msg, $pmpro_msgt, $current_user, $pmpro_currency_symbol, $pmpro_all_levels, $pmpro_visible_levels, $current_user, $membership_levels; //turn 0's into falses if ($back_link === "0" || $back_link === "false" || $back_link === "no") { $back_link = false; } else { $back_link = true; } if ($compare === "0" || $compare === "false" || $compare === "no") { $compare = false; } else { $compareitems = explode(";", $compare); } if ($description === "0" || $description === "false" || $description === "no") { $description = false; } else { $description = true; } if ($expiration === "0" || $expiration === "false" || $expiration === "no") { $expiration = false; } else { $expiration = true; } if ($more_button === "0" || $more_button === "false" || $more_button === "no" || empty($more_button)) { $more_button = false; } elseif ($more_button === "1" || $more_button === "true" || $more_button === "yes") { $more_button = "Read More"; } if ($price === "0" || $price === "false" || $price === "hide") { $show_price = false; } else { $show_price = true; } if (function_exists('pmpro_getAllLevels')) { ob_start(); //make sure pmpro_levels has all levels if (!isset($pmpro_all_levels)) { $pmpro_all_levels = pmpro_getAllLevels(true, true); } if (!isset($pmpro_visible_levels)) { $pmpro_visible_levels = pmpro_getAllLevels(false, true); } if ($pmpro_msg) { ?> <div class="pmpro_message <?php echo $pmpro_msgt; ?> "><?php echo $pmpro_msg; ?> </div> <?php } $pmpro_levels_filtered = array(); if (!empty($levels)) { $levels_order = explode(",", $levels); //loop through $levels_order array and pull levels from $levels foreach ($levels_order as $level_id) { foreach ($pmpro_all_levels as $level) { if ($level->id == $level_id) { $pmpro_levels_filtered[$level->id] = $level; break; } } } } else { $pmpro_levels_filtered = $pmpro_visible_levels; } $pmpro_levels_filtered = apply_filters("pmpro_levels_array", $pmpro_levels_filtered); $numeric_levels_array = array_values($pmpro_levels_filtered); //update per discount code if (!empty($discount_code) && !empty($pmpro_levels_filtered)) { foreach ($pmpro_levels_filtered as $level_id => $level) { //check code for this level and update if applicable if (pmpro_checkDiscountCode($discount_code, $level->id)) { $sqlQuery = "SELECT l.id, cl.*, l.name, l.description, l.allow_signups FROM {$wpdb->pmpro_discount_codes_levels} cl LEFT JOIN {$wpdb->pmpro_membership_levels} l ON cl.level_id = l.id LEFT JOIN {$wpdb->pmpro_discount_codes} dc ON dc.id = cl.code_id WHERE dc.code = '" . $discount_code . "' AND cl.level_id = '" . (int) $level->id . "' LIMIT 1"; $pmpro_levels_filtered[$level_id] = $wpdb->get_row($sqlQuery); $pmpro_levels_filtered[$level_id]->base_level = $level; } } } if ($layout == 'table') { ?> <table id="pmpro_levels" class="pmpro_levels-table"> <thead> <tr> <th><?php _e('Level', 'pmpro'); ?> </th> <?php if (!empty($show_price)) { ?> <th><?php _e('Price', 'pmpro'); ?> </th> <?php } ?> <?php if (!empty($expiration)) { ?> <th><?php _e('Expiration', 'pmpro'); ?> </th> <?php } ?> <th> </th> </tr> </thead> <tbody> <?php $count = 0; foreach ($pmpro_levels_filtered as $level) { if (isset($current_user->membership_level->ID)) { $current_level = $current_user->membership_level->ID == $level->id; } else { $current_level = false; } ?> <tr class="<?php if ($current_level) { echo 'pmpro_level-current '; } if ($highlight == $level->id) { echo 'pmpro_level-highlight '; } ?> "> <td> <h2><?php echo $level->name; ?> </h2> <?php if (!empty($description)) { echo wpautop($level->description); } ?> <?php $level_page = memberlite_getLevelLandingPage($level->id); if (!empty($level_page)) { ?> <p><a href="<?php echo get_permalink($level_page->ID); ?> "><?php echo $more_button; ?> </a></p> <?php } ?> </td> <?php if (!empty($show_price)) { ?> <td> <?php if ($price === 'full') { echo memberlite_getLevelCost($level, true, false); } else { echo memberlite_getLevelCost($level, true, true); } ?> </td> <?php } ?> <?php if (!empty($expiration)) { ?> <td> <?php $level_expiration = pmpro_getLevelExpiration($level); if (empty($level_expiration)) { _e('Membership Never Expires.', 'pmpro'); } else { echo $level_expiration; } ?> </td> <?php } ?> <td> <?php if (empty($current_user->membership_level->ID)) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $checkout_button; ?> </a> <?php } elseif (!$current_level) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $checkout_button; ?> </a> <?php } elseif ($current_level) { ?> <?php //if it's a one-time-payment level, offer a link to renew if (!pmpro_isLevelRecurring($current_user->membership_level) && !empty($current_user->membership_level->enddate)) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $renew_button; ?> </a> <?php } else { ?> <a class="pmpro_btn disabled" href="<?php echo pmpro_url("account"); ?> "><?php echo $account_button; ?> </a> <?php } ?> <?php } ?> </td> </tr> <?php } ?> </tbody> </table> <?php } elseif ($layout == 'compare_table') { ?> <table id="pmpro_levels" class="pmpro_levels-compare_table"> <thead> <tr> <th><?php _e('Level', 'pmpro'); ?> </th> <?php $count = 0; foreach ($pmpro_levels_filtered as $level) { ?> <th class="<?php if ($current_level) { echo 'pmpro_level-current '; } if ($highlight == $level->id) { echo 'pmpro_level-highlight '; } ?> "> <h2><?php echo $level->name; ?> </h2> </th> <?php } ?> </tr> <?php if (!empty($show_price)) { ?> <tr> <th><?php _e('Price', 'pmpro'); ?> </th> <?php foreach ($pmpro_levels_filtered as $level) { ?> <th class="<?php if ($current_level) { echo 'pmpro_level-current '; } if ($highlight == $level->id) { echo 'pmpro_level-highlight '; } ?> "> <h1 class="primary"> <?php if ($price === 'full') { echo memberlite_getLevelCost($level, true, false); } else { echo memberlite_getLevelCost($level, true, true); } ?> </h1> </th> <?php } ?> </tr> <?php } ?> <?php if (!empty($expiration)) { ?> <tr> <th><?php _e('Expiration', 'pmpro'); ?> </th> <?php foreach ($pmpro_levels_filtered as $level) { ?> <th class="muted <?php if ($current_level) { echo 'pmpro_level-current '; } if ($highlight == $level->id) { echo 'pmpro_level-highlight '; } ?> "> <?php $level_expiration = pmpro_getLevelExpiration($level); if (empty($level_expiration)) { _e('Membership Never Expires.', 'pmpro'); } else { echo $level_expiration; } ?> </th> <?php } ?> </tr> <?php } ?> <tr> <th> </th> <?php foreach ($pmpro_levels_filtered as $level) { ?> <th class="<?php if ($current_level) { echo 'pmpro_level-current '; } if ($highlight == $level->id) { echo 'pmpro_level-highlight '; } ?> "> <?php if (empty($current_user->membership_level->ID)) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $checkout_button; ?> </a> <?php } elseif (!$current_level) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $checkout_button; ?> </a> <?php } elseif ($current_level) { ?> <?php //if it's a one-time-payment level, offer a link to renew if (!pmpro_isLevelRecurring($current_user->membership_level) && !empty($current_user->membership_level->enddate)) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $renew_button; ?> </a> <?php } else { ?> <a class="pmpro_btn disabled" href="<?php echo pmpro_url("account"); ?> "><?php echo $account_button; ?> </a> <?php } ?> <?php } ?> </th> <?php } ?> </tr> </thead> <tbody> <?php if (!empty($compareitems)) { //var_dump($compareitems); foreach ($compareitems as $compareitem) { ?> <tr> <?php $count = -1; $compareitem_values = explode(",", $compareitem); foreach ($compareitem_values as $compareitem_value) { if ($count > 0 && !empty($numeric_levels_array[$count])) { $level = $numeric_levels_array[$count]; } else { $level = NULL; } $count++; ?> <td class="<?php if ($current_level) { echo 'pmpro_level-current '; } if (!empty($level) && $highlight == $level->id) { echo 'pmpro_level-highlight '; } ?> "> <?php if ($compareitem_value == '1') { echo '<i class="fa fa-check fa-2x success"></i>'; } elseif ($compareitem_value == '0') { echo '<i class="fa fa-minus muted"></i>'; } else { echo $compareitem_value; } ?> </td> <?php } ?> </tr> <?php } } ?> </tbody> <tfoot> <tr> <td> </td> <?php foreach ($pmpro_levels_filtered as $level) { ?> <td class="<?php if ($current_level) { echo 'pmpro_level-current '; } if (!empty($level) && $highlight == $level->id) { echo 'pmpro_level-highlight '; } ?> "> <?php if (empty($current_user->membership_level->ID)) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $checkout_button; ?> </a> <?php } elseif (!$current_level) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $checkout_button; ?> </a> <?php } elseif ($current_level) { ?> <?php //if it's a one-time-payment level, offer a link to renew if (!pmpro_isLevelRecurring($current_user->membership_level) && !empty($current_user->membership_level->enddate)) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $renew_button; ?> </a> <?php } else { ?> <a class="pmpro_btn disabled" href="<?php echo pmpro_url("account"); ?> "><?php echo $account_button; ?> </a> <?php } ?> <?php } ?> </td> <?php } ?> </tr> <?php if (!empty($expiration)) { ?> <tr> <td><?php _e('Expiration', 'pmpro'); ?> </td> <?php foreach ($pmpro_levels_filtered as $level) { ?> <td class="muted <?php if ($current_level) { echo 'pmpro_level-current '; } if ($highlight == $level->id) { echo 'pmpro_level-highlight '; } ?> "> <?php $level_expiration = pmpro_getLevelExpiration($level); if (empty($level_expiration)) { _e('Membership Never Expires.', 'pmpro'); } else { echo $level_expiration; } ?> </td> <?php } ?> </tr> <?php } ?> <?php if (!empty($more_button)) { ?> <tr> <td><?php _e('More Information', 'pmpro'); ?> </td> <?php $count = 0; foreach ($pmpro_levels_filtered as $level) { ?> <td class="<?php if ($current_level) { echo 'pmpro_level-current '; } if (!empty($level) && $highlight == $level->id) { echo 'pmpro_level-highlight '; } ?> "> <?php $level_page = memberlite_getLevelLandingPage($level->id); if (!empty($level_page)) { ?> <a href="<?php echo get_permalink($level_page->ID); ?> "><?php echo $more_button; ?> </a> <?php } ?> </td> <?php } ?> </tr> <?php } ?> </tfoot> </table> <?php } else { ?> <div id="pmpro_levels" class="pmpro_levels-<?php echo $layout; ?> row"> <?php $count = 0; foreach ($pmpro_levels_filtered as $level) { $count++; if (isset($current_user->membership_level->ID)) { $current_level = $current_user->membership_level->ID == $level->id; } else { $current_level = false; } ?> <div class="medium-<?php if ($layout == 'div' || empty($layout)) { echo '12'; } elseif ($layout == '2col') { echo '6'; } elseif ($layout == '3col') { echo '4'; } elseif ($layout == '4col') { echo '3'; } else { if (count($pmpro_levels) > 1) { echo '12'; } } //if($count == 1 || ($layout == 'div' || empty($layout))) { echo '12'; } ?> columns"> <div class="hentry post <?php if ($current_level) { echo 'pmpro_level-current '; } if ($highlight == $level->id) { echo 'pmpro_level-highlight '; } ?> "> <h2><?php echo $level->name; ?> </h2> <?php if ((!empty($description) || !empty($more_button)) && ($layout == 'div' || $layout == '2col' || empty($layout))) { ?> <div class="entry-content"> <?php echo wpautop($level->description); ?> <?php $level_page = memberlite_getLevelLandingPage($level->id); if (!empty($level_page)) { ?> <p><a href="<?php echo get_permalink($level_page->ID); ?> "><?php echo $more_button; ?> </a></p> <?php } ?> </div> <?php } ?> <?php if ($layout == 'div' || $layout == '2col' || empty($layout)) { ?> <footer class="entry-footer"> <?php if (empty($current_user->membership_level->ID)) { ?> <a class="pmpro_btn pmpro_btn-select <?php if ($layout == 'div' || $layout == '2col' || empty($layout)) { echo 'alignright'; } ?> " href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $checkout_button; ?> </a> <?php } elseif (!$current_level) { ?> <a class="pmpro_btn pmpro_btn-select <?php if ($layout == 'div' || $layout == '2col' || empty($layout)) { echo 'alignright'; } ?> " href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $checkout_button; ?> </a> <?php } elseif ($current_level) { //if it's a one-time-payment level, offer a link to renew if (!pmpro_isLevelRecurring($current_user->membership_level) && !empty($current_user->membership_level->enddate)) { ?> <a class="pmpro_btn pmpro_btn-select <?php if ($layout == 'div' || $layout == '2col' || empty($layout)) { echo 'alignright'; } ?> " href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $renew_button; ?> </a> <?php } else { ?> <a class="pmpro_btn disabled <?php if ($layout == 'div' || $layout == '2col' || empty($layout)) { echo 'alignright'; } ?> " href="<?php echo pmpro_url("account"); ?> "><?php echo $account_button; ?> </a> <?php } } ?> <?php if (!empty($show_price)) { ?> <p class="pmpro_level-price"> <?php if (pmpro_isLevelFree($level)) { if (!empty($expiration)) { ?> <strong><?php _e('Free.', 'pmpro'); ?> </strong> <?php } else { ?> <strong><?php _e('Free', 'pmpro'); ?> </strong> <?php } } elseif ($price === 'full') { echo memberlite_getLevelCost($level, true, false); } else { echo memberlite_getLevelCost($level, true, true); } ?> </p> <?php } ?> <?php if (!empty($expiration)) { $level_expiration = pmpro_getLevelExpiration($level); if (empty($level_expiration)) { _e('Membership Never Expires.', 'pmpro'); } else { echo $level_expiration; } } ?> <?php if ($layout == 'div' || $layout == '2col' || empty($layout)) { echo '<div class="clear"></div>'; } ?> </footer> <!-- .entry-footer --> <?php } else { //This is a column-type div layout ?> <div class="entry-content"> <?php if (!empty($show_price)) { ?> <p class="pmpro_level-price"> <?php if ($price === 'full') { echo memberlite_getLevelCost($level, true, false); } else { echo memberlite_getLevelCost($level, true, true); } ?> </p> <?php } ?> <p class="pmpro_level-select"><?php if (empty($current_user->membership_level->ID)) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $checkout_button; ?> </a> <?php } elseif (!$current_level) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $checkout_button; ?> </a> <?php } elseif ($current_level) { //if it's a one-time-payment level, offer a link to renew if (!pmpro_isLevelRecurring($current_user->membership_level) && !empty($current_user->membership_level->enddate)) { ?> <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https"); ?> "><?php echo $renew_button; ?> </a> <?php } else { ?> <a class="pmpro_btn disabled" href="<?php echo pmpro_url("account"); ?> "><?php echo $account_button; ?> </a> <?php } } ?> </p> <?php if (!empty($description)) { echo wpautop($level->description); } ?> <?php $level_page = memberlite_getLevelLandingPage($level->id); if (!empty($level_page)) { ?> <p><a href="<?php echo get_permalink($level_page->ID); ?> "><?php echo $more_button; ?> </a></p> <?php } ?> </div> <!-- .entry-content --> <?php if (!empty($expiration)) { echo '<footer class="entry-footer pmpro_level-expiration">'; $level_expiration = pmpro_getLevelExpiration($level); if (empty($level_expiration)) { _e('Membership Never Expires.', 'pmpro'); } else { echo $level_expiration; } echo '</footer>'; } ?> <?php } ?> </div></div> <?php } ?> </div> <!-- #pmpro_levels, .row --> <?php } //end else if no layout specified, use 'div' ?> <?php if (!is_page_template('templates/interstitial.php') && !empty($back_link)) { ?> <nav id="nav-below" class="navigation" role="navigation"> <div class="nav-previous alignleft"> <?php if (!empty($current_user->membership_level->ID)) { ?> <a href="<?php echo pmpro_url("account"); ?> "><?php _e('← Return to Your Account', 'pmpro'); ?> </a> <?php } else { ?> <a href="<?php echo home_url(); ?> "><?php _e('← Return to Home', 'pmpro'); ?> </a> <?php } ?> </div> </nav> <?php } ?> <?php $temp_content = ob_get_contents(); ob_end_clean(); return $temp_content; } }
/** * Code added to checkout preheader. * * @since 1.8 */ static function pmpro_checkout_preheader() { global $gateway, $pmpro_level; if ($gateway == "stripe" && !pmpro_isLevelFree($pmpro_level)) { //stripe js library wp_enqueue_script("stripe", "https://js.stripe.com/v2/", array(), NULL); //stripe js code for checkout function pmpro_stripe_javascript() { global $pmpro_gateway, $pmpro_level, $pmpro_stripe_lite; ?> <script type="text/javascript"> <!-- // this identifies your website in the createToken call below Stripe.setPublishableKey('<?php echo pmpro_getOption("stripe_publishablekey"); ?> '); var pmpro_require_billing = true; jQuery(document).ready(function() { jQuery("#pmpro_form, .pmpro_form").submit(function(event) { //double check in case a discount code made the level free if(pmpro_require_billing) { //build array for creating token var args = { number: jQuery('#AccountNumber').val(), exp_month: jQuery('#ExpirationMonth').val(), exp_year: jQuery('#ExpirationYear').val() <?php $pmpro_stripe_verify_address = apply_filters("pmpro_stripe_verify_address", pmpro_getOption('stripe_billingaddress')); if (!empty($pmpro_stripe_verify_address)) { ?> ,address_line1: jQuery('#baddress1').val(), address_line2: jQuery('#baddress2').val(), address_city: jQuery('#bcity').val(), address_state: jQuery('#bstate').val(), address_zip: jQuery('#bzipcode').val(), address_country: jQuery('#bcountry').val() <?php } ?> }; //add CVC if not blank if(jQuery('#CVV').val().length) args['cvc'] = jQuery('#CVV').val(); //add first and last name if not blank if (jQuery('#bfirstname').length && jQuery('#blastname').length) args['name'] = jQuery.trim(jQuery('#bfirstname').val() + ' ' + jQuery('#blastname').val()); //create token Stripe.createToken(args, stripeResponseHandler); // prevent the form from submitting with the default action return false; } else return true; //not using Stripe anymore }); }); function stripeResponseHandler(status, response) { if (response.error) { // re-enable the submit button jQuery('.pmpro_btn-submit-checkout').removeAttr("disabled"); //hide processing message jQuery('#pmpro_processing_message').css('visibility', 'hidden'); // show the errors on the form alert(response.error.message); jQuery(".payment-errors").text(response.error.message); } else { var form$ = jQuery("#pmpro_form, .pmpro_form"); // token contains id, last4, and card type var token = response['id']; // insert the token into the form so it gets submitted to the server form$.append("<input type='hidden' name='stripeToken' value='" + token + "'/>"); //console.log(response); //insert fields for other card fields if(jQuery('#CardType[name=CardType]').length) jQuery('#CardType').val(response['card']['brand']); else form$.append("<input type='hidden' name='CardType' value='" + response['card']['brand'] + "'/>"); form$.append("<input type='hidden' name='AccountNumber' value='XXXXXXXXXXXXX" + response['card']['last4'] + "'/>"); form$.append("<input type='hidden' name='ExpirationMonth' value='" + ("0" + response['card']['exp_month']).slice(-2) + "'/>"); form$.append("<input type='hidden' name='ExpirationYear' value='" + response['card']['exp_year'] + "'/>"); // and submit form$.get(0).submit(); } } --> </script> <?php } add_action("wp_head", "pmpro_stripe_javascript"); //don't require the CVV function pmpro_stripe_dont_require_CVV($fields) { unset($fields['CVV']); return $fields; } add_filter("pmpro_required_billing_fields", "pmpro_stripe_dont_require_CVV"); } }
if (!empty($cost_text) && !empty($expiration_text)) { echo $cost_text . $expiration_text; } elseif (!empty($cost_text)) { echo $cost_text; } elseif (!empty($expiration_text)) { echo $expiration_text; } ?> </span> </div><!-- /.col-md-5.columns --> <div class="col-md-3 columns text-left"> <ul class="list-unstyled"> <?php foreach ($javo_membership as $item) { if (!pmpro_isLevelFree($lv)) { if (!$item['unlimited']) { if ((int) $item['amount'] > 0) { echo "<li class='attribute'><span><i class='{$item['icon']}'></i> {$item['label']} {$item['amount']} {$item['suffix']}</span></li>"; } else { echo "<li class='attribute disabled'><span><i class='{$item['icon']}'></i> {$item['no_use']}</span></li>"; } } else { echo "<li class='attribute'><span><i class='{$item['icon']}'></i> {$item['unlimited_str']}</span></li>"; } } else { // IT IS FREE LEVEL echo "<li class='attribute x3'></li>"; } // FOREACH }
} $expiration_text = pmpro_getLevelExpiration($level); if ($expiration_text) { ?> <br /><span class="pmpro_level-expiration"><?php echo $expiration_text; ?> </span> <?php } ?> <div class="pmpro-price"> <p class="lead"> <?php if (pmpro_isLevelFree($level) || $level->initial_payment === "0.00") { ?> <?php echo $pmpro_currency_symbol; _e('0', 'pmpro'); ?> <?php } else { $l_price = explode(".", $level->initial_payment); echo $pmpro_currency_symbol; echo $l_price[0]; if (isset($l_price[1])) { echo '<sup>.' . $l_price[1] . '</sup>'; } } ?>
function pmproap_getLevelIDForCheckoutLink($post_id = NULL, $user_id = NULL) { global $current_user, $post; //default to current user if (empty($user_id) && !empty($current_user) && !empty($current_user->ID)) { $user_id = $current_user->ID; } //default to current post if (empty($post_id) && !empty($post) && !empty($post->ID)) { $post_id = $post->ID; } //no post, we bail if (empty($post_id)) { return false; } //no user id? make sure it's null if (empty($user_id)) { $user_id = NULL; } //use current level or offer a free level checkout $has_access = pmpro_has_membership_access($post_id, $user_id, true); $post_levels = $has_access[1]; //make sure membership_level obj is populated if (is_user_logged_in()) { $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID); } if (!empty($current_user->membership_level) && in_array($current_user->membership_level->ID, $post_levels)) { $text_level_id = $current_user->membership_level->id; } elseif (!empty($post_levels)) { //find a free level to checkout with foreach ($post_levels as $post_level_id) { $post_level = pmpro_getLevel($post_level_id); if (pmpro_isLevelFree($post_level)) { $text_level_id = $post_level->id; break; } } } //didn't find a level id to use yet? return false and user's will be linked to the levels page. if (empty($text_level_id)) { $text_level_id = false; } return $text_level_id; }
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"] extract(shortcode_atts(array('level' => NULL, 'short' => NULL, 'intro' => true, 'button' => "Signup »"), $atts)); //turn 0's into falses if ($short === "0" || $short === "false" || $short === "no") { $short = false; } else { $short = true; } if ($intro === "0" || $intro === "false" || $intro === "no") { $intro = false; } else { $intro = true; } global $current_user, $membership_levels; ob_start(); ?> <?php if (!empty($current_user->ID)) { ?> <p>You are logged in as <?php echo $current_user->user_login; ?> .</p> <?php } else { ?> <form class="pmpro_form" action="<?php echo pmpro_url("checkout"); ?> " method="post"> <?php if ($intro) { echo wpautop("Register for " . pmpro_getLevel($level)->name . "."); } ?> <input type="hidden" id="level" name="level" value="<?php echo $level; ?> " /> <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="text" 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="text" 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 || $recaptcha == 1 && pmpro_isLevelFree($pmpro_level)) { echo recaptcha_get_html($recaptcha_publickey, NULL, true); } ?> </div> <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> </form> <?php } ?> <?php $temp_content = ob_get_contents(); ob_end_clean(); return $temp_content; }
function sendCheckoutAdminEmail($user = NULL, $invoice = NULL) { global $wpdb, $current_user; if (!$user) { $user = $current_user; } if (!$user) { return false; } //check settings $send = pmpro_getOption("email_admin_checkout"); if (empty($send)) { return true; } //didn't send, but we also don't want to indicate failure because the settings say to not send $this->email = get_bloginfo("admin_email"); $this->subject = sprintf(__("Member Checkout for %s at %s", "pmpro"), $user->membership_level->name, get_option("blogname")); $this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"), "membership_id" => $user->membership_level->id, "membership_level_name" => $user->membership_level->name, "membership_cost" => pmpro_getLevelCost($user->membership_level), "login_link" => wp_login_url(pmpro_url("account")), "display_name" => $user->display_name, "user_email" => $user->user_email); if (!empty($invoice) && !pmpro_isLevelFree($user->membership_level)) { if ($invoice->gateway == "paypalexpress") { $this->template = "checkout_express_admin"; } elseif ($invoice->gateway == "check") { $this->template = "checkout_check_admin"; } elseif (pmpro_isLevelTrial($user->membership_level)) { $this->template = "checkout_trial_admin"; } else { $this->template = "checkout_paid_admin"; } $this->data["invoice_id"] = $invoice->code; $this->data["invoice_total"] = pmpro_formatPrice($invoice->total); $this->data["invoice_date"] = date_i18n(get_option('date_format'), $invoice->timestamp); $this->data["billing_name"] = $invoice->billing->name; $this->data["billing_street"] = $invoice->billing->street; $this->data["billing_city"] = $invoice->billing->city; $this->data["billing_state"] = $invoice->billing->state; $this->data["billing_zip"] = $invoice->billing->zip; $this->data["billing_country"] = $invoice->billing->country; $this->data["billing_phone"] = $invoice->billing->phone; $this->data["cardtype"] = $invoice->cardtype; $this->data["accountnumber"] = hideCardNumber($invoice->accountnumber); $this->data["expirationmonth"] = $invoice->expirationmonth; $this->data["expirationyear"] = $invoice->expirationyear; $this->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); if ($invoice->getDiscountCode()) { $this->data["discount_code"] = "<p>" . __("Discount Code", "pmpro") . ": " . $invoice->discount_code->code . "</p>\n"; } else { $this->data["discount_code"] = ""; } } elseif (pmpro_isLevelFree($user->membership_level)) { $this->template = "checkout_free_admin"; global $discount_code; if (!empty($discount_code)) { $this->data["discount_code"] = "<p>" . __("Discount Code", "pmpro") . ": " . $discount_code . "</p>\n"; } else { $this->data["discount_code"] = ""; } } else { $this->template = "checkout_freetrial_admin"; $this->data["discount_code"] = ""; } $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM {$wpdb->pmpro_memberships_users} WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1"); if ($enddate) { $this->data["membership_expiration"] = "<p>" . sprintf(__("This membership will expire on %s.", "pmpro"), date_i18n(get_option('date_format'), $enddate)) . "</p>\n"; } else { $this->data["membership_expiration"] = ""; } return $this->sendEmail(); }
$confirmation_message .= "\n" . stripslashes($level_message) . "\n"; } ?> <?php if (!empty($pmpro_invoice)) { ?> <?php $pmpro_invoice->getUser(); $pmpro_invoice->getMembershipLevel(); $confirmation_message .= "<p>" . sprintf(__('Below are details about your membership account and a receipt for your initial membership invoice. A welcome email with a copy of your initial membership invoice has been sent to %s.', 'pmpro'), $pmpro_invoice->user->user_email) . "</p>"; //check instructions if ($pmpro_invoice->gateway == "check" && !pmpro_isLevelFree($pmpro_invoice->membership_level)) { $confirmation_message .= wpautop(pmpro_getOption("instructions")); } $confirmation_message = apply_filters("pmpro_confirmation_message", $confirmation_message, $pmpro_invoice); echo apply_filters("the_content", $confirmation_message); ?> <h3> <?php printf(__('Invoice #%s on %s', 'pmpro'), $pmpro_invoice->code, date_i18n(get_option('date_format'), $pmpro_invoice->timestamp)); ?> </h3> <a class="pmpro_a-print" href="javascript:window.print()"><?php _e('Print', 'pmpro');
<?php global $current_user, $pmpro_invoice; //must be logged in if(empty($current_user->ID) || empty($current_user->membership_level->ID)) wp_redirect(home_url()); //if membership is a paying one, get invoice from DB if(!pmpro_isLevelFree($current_user->membership_level)) { $pmpro_invoice = new MemberOrder(); $pmpro_invoice->getLastMemberOrder($current_user->ID, apply_filters("pmpro_confirmation_order_status", array("success", "pending"))); } ?>