<?php if (!$user_id) { $user = wp_get_current_user(); $spmemuserid = $user->ID; if (!empty($user->ID) && is_numeric($user->ID)) { $member = new M_Membership($user->ID); } else { $member = current_member(); } } else { $member = new M_Membership($user_id); } $subscription = (int) $_REQUEST['subscription']; if (isset($_REQUEST['gateway']) && isset($_REQUEST['extra_form'])) { $gateway = M_get_class_for_gateway($_REQUEST['gateway']); if ($gateway && is_object($gateway) && $gateway->haspaymentform == true) { $sub = new M_Subscription($subscription); $pricing = $sub->get_pricingarray(); $coupon_code = membership_get_current_coupon(); if (!empty($pricing) && !empty($coupon_code)) { $pricing = $sub->apply_coupon_pricing($coupon_code, $pricing); } ?> <div class='header' style='width: 750px'> <h1><?php echo __('Enter Your Credit Card Information', 'membership') . " " . $sub->sub_name(); ?> </h1> </div> <div class='fullwidth'>
function check_for_membership_pages($posts) { global $M_options; if (count($posts) == 1) { // We have only the one post, so check if it's one of our pages $post = $posts[0]; if ($post->post_type == 'page') { if ($post->ID == $M_options['registration_page']) { // check if page contains a shortcode if (strstr($post->post_content, '[subscriptionform]') !== false) { // There is content in there with the shortcode so just return it return $posts; } else { // registration page found - add in the styles if (!current_theme_supports('membership_subscription_form')) { wp_enqueue_style('subscriptionformcss', membership_url('membershipincludes/css/subscriptionform.css')); wp_enqueue_style('publicformscss', membership_url('membershipincludes/css/publicforms.css')); wp_enqueue_style('buttoncss', membership_url('membershipincludes/css/buttons.css')); if ($M_options['formtype'] == 'new') { // pop up registration form wp_enqueue_style('fancyboxcss', membership_url('membershipincludes/js/fancybox/jquery.fancybox-1.3.4.css')); wp_enqueue_script('fancyboxjs', membership_url('membershipincludes/js/fancybox/jquery.fancybox-1.3.4.pack.js'), array('jquery'), false, true); wp_enqueue_script('popupmemjs', membership_url('membershipincludes/js/popupregistration.js'), array('jquery'), false, true); wp_enqueue_style('popupmemcss', membership_url('membershipincludes/css/popupregistration.css')); wp_localize_script('popupmemjs', 'membership', array('ajaxurl' => admin_url('admin-ajax.php'), 'registernonce' => wp_create_nonce('membership_register'), 'loginnonce' => wp_create_nonce('membership_login'), 'regproblem' => __('Problem with registration.', 'membership'), 'logpropblem' => __('Problem with Login.', 'membership'), 'regmissing' => __('Please ensure you have completed all the fields', 'membership'), 'regnomatch' => __('Please ensure passwords match', 'membership'), 'logmissing' => __('Please ensure you have entered an username or password', 'membership'))); } } do_action('membership_subscriptionbutton_onpage'); // There is no shortcode content in there, so override remove_filter('the_content', 'wpautop'); $post->post_content .= $this->do_subscription_form(); } } if ($post->ID == $M_options['account_page']) { // account page - check if page contains a shortcode if (strstr($post->post_content, '[accountform]') !== false || strstr($post->post_content, '[upgradeform]') !== false || strstr($post->post_content, '[renewform]') !== false) { // There is content in there with the shortcode so just return it return $posts; } else { // account page found - add in the styles if (!current_theme_supports('membership_account_form')) { wp_enqueue_style('accountformcss', membership_url('membershipincludes/css/accountform.css')); wp_enqueue_script('accountformjs', membership_url('membershipincludes/js/accountform.js'), array('jquery')); wp_enqueue_style('publicformscss', membership_url('membershipincludes/css/publicforms.css')); wp_enqueue_style('buttoncss', membership_url('membershipincludes/css/buttons.css')); } // There is no shortcode in there, so override remove_filter('the_content', 'wpautop'); $post->post_content .= $this->do_account_form(); } } if ($post->ID == $M_options['subscriptions_page']) { // Handle any updates passed $page = isset($_REQUEST['action']) ? addslashes($_REQUEST['action']) : ''; if (empty($page)) { $page = 'renewform'; } switch ($page) { case 'subscriptionsignup': if (is_user_logged_in()) { $member = current_member(); list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']); if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) { $gateway = $_POST['gateway']; // Join the new subscription $member->create_subscription($sub_id, $gateway); do_action('membership_payment_subscr_signup', $user_id, $sub_id); // Timestamp the update update_user_meta($user_id, '_membership_last_upgraded', time()); // Added another redirect to the same url because the show_no_access filters // have already run on the "parse_request" action (Cole) wp_redirect(M_get_subscription_permalink()); exit; } } else { // check if a custom is posted and of so then process the user if (isset($_POST['custom'])) { list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']); if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) { $gateway = $_POST['gateway']; // Join the new subscription $member = new M_Membership($user_id); $member->create_subscription($sub_id, $gateway); do_action('membership_payment_subscr_signup', $user_id, $sub_id); // Timestamp the update update_user_meta($user_id, '_membership_last_upgraded', time()); // Added another redirect to the same url because the show_no_access filters // have already run on the "parse_request" action (Cole) wp_redirect(M_get_subscription_permalink()); exit; } } } break; default: break; } // account page - check if page contains a shortcode if (strstr($post->post_content, '[upgradeform]') !== false || strstr($post->post_content, '[renewform]') !== false) { // There is content in there with the shortcode so just return it return $posts; } else { // account page found - add in the styles if (!current_theme_supports('membership_account_form')) { wp_enqueue_style('subscriptionformcss', membership_url('membershipincludes/css/subscriptionform.css')); wp_enqueue_style('upgradeformcss', membership_url('membershipincludes/css/upgradeform.css')); wp_enqueue_style('renewformcss', membership_url('membershipincludes/css/renewform.css')); wp_enqueue_script('renewformjs', membership_url('membershipincludes/js/renewform.js'), array('jquery')); wp_localize_script('renewformjs', 'membership', array('unsubscribe' => __('Are you sure you want to unsubscribe from this subscription?', 'membership'), 'deactivatelevel' => __('Are you sure you want to deactivate this level?', 'membership'))); wp_enqueue_style('publicformscss', membership_url('membershipincludes/css/publicforms.css')); wp_enqueue_style('buttoncss', membership_url('membershipincludes/css/buttons.css')); if ($M_options['formtype'] == 'new') { // pop up registration form wp_enqueue_style('fancyboxcss', membership_url('membershipincludes/js/fancybox/jquery.fancybox-1.3.4.css')); wp_enqueue_script('fancyboxjs', membership_url('membershipincludes/js/fancybox/jquery.fancybox-1.3.4.pack.js'), array('jquery'), false, true); wp_enqueue_script('popupmemjs', membership_url('membershipincludes/js/popupregistration.js'), array('jquery'), false, true); wp_enqueue_style('popupmemcss', membership_url('membershipincludes/css/popupregistration.css')); wp_localize_script('popupmemjs', 'membership', array('ajaxurl' => admin_url('admin-ajax.php'), 'registernonce' => wp_create_nonce('membership_register'), 'loginnonce' => wp_create_nonce('membership_login'), 'regproblem' => __('Problem with registration.', 'membership'), 'logpropblem' => __('Problem with Login.', 'membership'), 'regmissing' => __('Please ensure you have completed all the fields', 'membership'), 'regnomatch' => __('Please ensure passwords match', 'membership'), 'logmissing' => __('Please ensure you have entered an username or password', 'membership'))); } } // There is no shortcode in there, so override remove_filter('the_content', 'wpautop'); $post->post_content .= $this->do_renew_form(); } } if ($post->ID == $M_options['nocontent_page']) { // no access page - we must return the content entered by the user so just return it return $posts; } // Registration complete page if ($post->ID == $M_options['registrationcompleted_page']) { // Handle any updates passed if (isset($_REQUEST['action']) && !empty($_REQUEST['action'])) { $page = addslashes($_REQUEST['action']); } else { $page = 'renewform'; } switch ($page) { case 'subscriptionsignup': if (is_user_logged_in() && isset($_POST['custom'])) { list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']); if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) { $member = current_member(); $gateway = $_POST['gateway']; // Join the new subscription $member->create_subscription($sub_id, $gateway); do_action('membership_payment_subscr_signup', $user_id, $sub_id); // Timestamp the update update_user_meta($user_id, '_membership_last_upgraded', time()); // Added another redirect to the same url because the show_no_access filters // have already run on the "parse_request" action (Cole) wp_redirect(M_get_returnurl_permalink()); exit; } else { } } else { // check if a custom is posted and of so then process the user if (isset($_POST['custom'])) { list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']); if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) { $gateway = $_POST['gateway']; // Join the new subscription $member = new M_Membership($user_id); $member->create_subscription($sub_id, $gateway); do_action('membership_payment_subscr_signup', $user_id, $sub_id); // Timestamp the update update_user_meta($user_id, '_membership_last_upgraded', time()); // Added another redirect to the same url because the show_no_access filters // have already run on the "parse_request" action (Cole) wp_redirect(M_get_returnurl_permalink()); exit; } } } break; } return $posts; } } } // If nothing else is hit, just return the content return $posts; }
function popover_payment_form() { global $M_options; $gateway = $_POST['gateway']; if ($gateway == 'authorizenetarb') { $subscription_id = $_POST['subscription']; $coupon_code = $_POST['coupon_code']; $user_id = $_POST['user']; $factory = Membership_Plugin::factory(); if (empty($user_id)) { $user = wp_get_current_user(); $spmemuserid = $user->ID; if (!empty($user->ID) && is_numeric($user->ID)) { $member = $factory->get_member($user->ID); } else { $member = current_member(); } } else { $member = $factory->get_member($user_id); } $subscription = (int) $_REQUEST['subscription']; $gateway = M_get_class_for_gateway($gateway); if ($gateway && is_object($gateway) && $gateway->haspaymentform == true) { $sub = $factory->get_subscription($subscription); // Get the coupon $coupon = membership_get_current_coupon(); // Build the pricing array $pricing = $sub->get_pricingarray(); if (!empty($pricing) && !empty($coupon)) { $pricing = $coupon->apply_coupon_pricing($pricing); } // Check if the pricing is now a free subscription and if so then handle the signup directly // We are on a free signup - check the subscription then set it up if (isset($pricing[0]) && $pricing[0]['amount'] < 1 && count($pricing) == 1 || count($pricing) == 2 && $pricing[0]['amount'] < 1 && $pricing[1]['amount'] < 1) { // We have a free level $member->create_subscription($subscription_id, $this->gateway); if (!empty($M_options['registrationcompleted_message'])) { echo $this->get_completed_message($sub); } else { wp_safe_redirect(!strpos(home_url(), 'https:') ? str_replace('https:', 'http:', M_get_registrationcompleted_permalink()) : M_get_registrationcompleted_permalink()); } } else { ?> <div class='header' style='width: 750px'> <h1><?php echo __('Enter Your Credit Card Information', 'membership'); ?> </h1> </div> <?php $this->display_payment_form($sub, $pricing, $member->ID); } } } // Need this to stop processing die; }
/** * Renders renew subscriptions. * * @since 3.5 * * @access private * @global membershippublic $membershippublic The global membershippublic object. * @global array $M_options The settings array. */ private function _render_renew_subscription() { global $membershippublic, $M_options; $factory = Membership_Plugin::factory(); // The user has a subscription so we can display it with the information $member = current_member(); $rels = array_filter((array) $member->get_relationships()); if (empty($M_options['renewalperiod'])) { $M_options['renewalperiod'] = 7; } $success_msg = __('Your current subscriptions are listed here. You can renew, cancel or upgrade your subscriptions by using the forms below.', 'membership'); ?> <div id="membership-wrapper"> <legend><?php echo __('Your Subscriptions', 'membership'); ?> </legend> <div class="alert alert-success"> <?php echo $success_msg; ?> </div> <div class="priceboxes"><?php foreach ($rels as $rel) { $sub = $factory->get_subscription($rel->sub_id); $nextlevel = $sub->get_next_level($rel->level_id, $rel->order_instance); $currentlevel = $sub->get_level_at($rel->level_id, $rel->order_instance); $expire_date = mysql2date('U', $rel->expirydate); $expire_date_string = date_i18n(get_option('date_format'), $expire_date); if (!empty($rel->usinggateway) && $rel->usinggateway != 'admin') { $gateway = Membership_Gateway::get_gateway($rel->usinggateway); if (!empty($gateway) && $gateway->issingle) { $gatewayissingle = 'yes'; } else { $gatewayissingle = 'no'; } } else { $gatewayissingle = 'admin'; } ?> <div class="pricebox subscribedbox" id="subscribedbox-<?php echo $sub->id; ?> "> <div class="topbar"> <span class="title"><?php echo $sub->sub_name(); ?> </span> </div> <div class="pricedetails"><?php if ($member->is_marked_for_expire($rel->sub_id)) { echo sprintf(__('Your membership has been cancelled and will expire on: <strong>%s</strong>', 'membership'), $expire_date_string); } else { if ($currentlevel->sub_type == 'indefinite') { echo __('You are on an <strong>indefinite</strong> membership.', 'membership'); } elseif ($gatewayissingle == 'yes') { echo sprintf(__('Your membership is due to expire on: <strong>%s</strong> ', 'membership'), $expire_date_string); } else { // Serial gateway switch ($currentlevel->sub_type) { case 'serial': echo __('Your membership is set to <strong>automatically renew</strong>', 'membership'); break; case 'finite': if (!empty($nextlevel)) { // We have a level we can move to next echo __('Your membership is set to <strong>automatically renew</strong>', 'membership'); } else { echo sprintf(__('Your membership is due to expire on: <strong>%s</strong> ', 'membership'), $expire_date_string); } break; } } } // Get the last upgrade time $upgradedat = get_user_meta($member->ID, '_membership_last_upgraded', true); if (empty($upgradedat)) { $upgradedat = strtotime('-1 year'); } $period = isset($M_options['upgradeperiod']) ? $M_options['upgradeperiod'] : 1; if (empty($period) && $period != 0) { $period = 1; } if (!$member->is_marked_for_expire($rel->sub_id) && $gatewayissingle == 'yes') { $renewalperiod = strtotime('-' . $M_options['renewalperiod'] . ' days', $expire_date); if ($nextlevel && time() >= $renewalperiod) { // we have a next level so we can display the details and form for it if ($member->has_active_payment($rel->sub_id, $nextlevel->level_id, $nextlevel->level_order)) { ?> <legend><?php echo __('Renewal your subscription', 'membership'); ?> </legend> <div class="renew-form"> <div class="formleft"> <p><?php printf(__('Renewal for the %s following %s has been completed.', 'membership'), sprintf('<strong>%s %s</strong>', $nextlevel->level_period, $this->_get_period($nextlevel->level_period_unit, $nextlevel->level_period)), $expire_date_string); ?> </p> </div> </div> <!-- renew-form --><?php } else { ?> <div class="renew-form"> <div class="formleft"> <p><?php printf($nextlevel->level_price > 0 ? __('To renew your subscription for another %s following %s you will need to pay %s.', 'membership') : __('To renew your subscription for another %s following %s click on the button to the right.', 'membership'), sprintf('<strong>%s %s</strong>', $nextlevel->level_period, $this->_get_period($nextlevel->level_period_unit, $nextlevel->level_period)), $expire_date_string, sprintf('<strong>%s %s</strong>', $nextlevel->level_price, apply_filters('membership_real_currency_display', $M_options['paymentcurrency']))); // Need to put in coupon code bit here in case they have signed up with one $gateway->display_subscribe_button($sub, $sub->get_pricingarray(), $member->ID, $nextlevel->level_order); ?> </p> </div> </div> <!-- renew-form --> <?php } } } ?> </div> <div class="bottombar"> <div style="float:right;margin-right:10px"><?php if (!$member->is_marked_for_expire($rel->sub_id)) { if ($gatewayissingle != 'admin' && method_exists($gateway, 'display_cancel_button')) { $gateway->display_cancel_button($sub, $sub->get_pricingarray(), $member->ID); } else { ?> <form class="unsubbutton" method="post"> <input type="hidden" name="action" value="unsubscribe"> <input type="hidden" name="gateway" value="admin"> <input type="hidden" name="subscription" value="<?php echo esc_attr($rel->sub_id); ?> "> <input type="hidden" name="user" value="<?php echo esc_attr($member->ID); ?> "> <?php wp_nonce_field('cancel-sub_' . $rel->sub_id); ?> <input type="submit" value="<?php esc_attr_e('Unsubscribe', 'membership'); ?> " class="button <?php echo apply_filters('membership_subscription_button_color', ''); ?> "> </form><?php } } ?> </div> </div> </div> <!-- price box --><?php if ($upgradedat <= strtotime('-' . $period . ' days') || !current_user_has_subscription() && !empty($M_options['freeusersubscription'])) { $upgradesubs = array(); foreach (array_filter((array) apply_filters('membership_override_upgrade_subscriptions', $membershippublic->get_subscriptions())) as $upgradesub) { if ($upgradesub->id == $rel->sub_id || $member->on_sub($upgradesub->id)) { // Don't want to show our current subscription as we will display this above. continue; } $upgradesubs[] = $upgradesub; } // Show upgrades if (!empty($upgradesubs)) { ?> <legend class="upgradefrom-<?php echo $sub->id; ?> "> <?php printf(_x('Upgrade from %s', 'Upgrade from {subscription name}', 'membership'), $sub->sub_name()); ?> </legend><?php } foreach ($upgradesubs as $upgradesub) { $subscription = $factory->get_subscription($upgradesub->id); ?> <div class="pricebox upgradebox upgradefrom-<?php echo $sub->id; ?> " id="upgradebox-<?php echo $subscription->id; ?> "> <div class="topbar"> <span class="title"> <strong><?php _ex('Move to:', 'Move to another subscription', 'membership'); ?> </strong> <?php echo $subscription->sub_name(); ?> </span> </div> <div class="pricedetails"> <?php echo $subscription->sub_description(); ?> </div> <div class="bottombar"> <div style="float:right;margin-right:10px"><?php // do an upgrade button $pricing = $subscription->get_pricingarray(); if (!empty($pricing)) { if ($gatewayissingle != 'admin') { if ($currentlevel->level_price < 1) { // We are on a free level, so need to do an upgrade from free if (method_exists($gateway, 'display_upgrade_from_free_button')) { $gateway->display_upgrade_from_free_button($subscription, $pricing, $member->ID, $rel->sub_id, $sub->id); } } else { // We want a normal upgrade button if (method_exists($gateway, 'display_upgrade_button')) { $gateway->display_upgrade_button($subscription, $pricing, $member->ID, $rel->sub_id); } } } else { $class = ''; if (isset($M_options['formtype']) && $M_options['formtype'] == 'new') { // pop up form $link = add_query_arg(array('action' => 'buynow', 'subscription' => $subscription->id, 'from_subscription' => $rel->sub_id), admin_url('admin-ajax.php')); $class = 'popover'; } else { // original form $link = add_query_arg(array('action' => 'registeruser', 'subscription' => $subscription->id, 'from_subscription' => $rel->sub_id), get_permalink($M_options['registration_page'])); } ?> <a href="<?php echo esc_url($link); ?> " class="button button-primary <?php echo $class; ?> <?php echo esc_attr(apply_filters('membership_subscription_button_color', '')); ?> "> <?php echo esc_html(apply_filters('membership_subscription_signup_text', __('Sign Up', 'membership'))); ?> </a><?php } } ?> </div> <span class="price"><?php echo $subscription->sub_pricetext(); ?> </span> </div> </div> <!-- pricebox --><?php } } } ?> </div> <!-- price boxes --> </div><!-- membership wrapper --><?php }
function check_for_membership_pages($posts) { global $M_options; if (count($posts) != 1) { return $posts; } // We have only the one post, so check if it's one of our pages $post = $posts[0]; if ($post->post_type != 'page') { return $posts; } if (membership_is_registration_page($post->ID, false) || M_contains_schortcode($post->post_content, 'subscriptionform')) { // Redirect members with subscriptions to the subscriptions page if it exists, else account page. global $member; $member = Membership_Plugin::current_member(); if (!empty($member)) { if ($member->has_subscription() && $member->ID != 0 && !isset($_REQUEST['from_subscription'])) { if (!empty($M_options['subscriptions_page'])) { wp_redirect(get_permalink($M_options['subscriptions_page'])); exit; } else { wp_redirect(get_permalink($M_options['account_page'])); exit; } } } add_action('template_redirect', array($this, 'process_subscription_form'), 1); if (strpos($post->post_content, '[subscriptionform]') !== false || strpos($post->post_content, '[renewform]') !== false) { // bail - shortcode found return $posts; } // registration page found - add in the styles if (!current_theme_supports('membership_subscription_form')) { wp_enqueue_style('membership-subscriptionformcss', MEMBERSHIP_ABSURL . 'css/subscriptionform.css', null, Membership_Plugin::VERSION); add_action('wp_head', array($this, 'enqueue_public_form_styles'), 99); $this->enqueue_fancybox_scripts(); } do_action('membership_subscriptionbutton_onpage'); // There is no shortcode content in there, so override remove_filter('the_content', 'wpautop'); } elseif (membership_is_account_page($post->ID, false)) { // account page - check if page contains a shortcode if (strpos($post->post_content, '[accountform]') !== false || strpos($post->post_content, '[upgradeform]') !== false || strpos($post->post_content, '[renewform]') !== false) { // There is content in there with the shortcode so just return it return $posts; } // account page found - add in the styles if (!current_theme_supports('membership_account_form')) { wp_enqueue_style('membership-accountformcss', MEMBERSHIP_ABSURL . 'css/accountform.css', null, Membership_Plugin::VERSION); wp_enqueue_script('membership-accountformjs', MEMBERSHIP_ABSURL . 'js/accountform.js', array('jquery'), Membership_Plugin::VERSION); add_action('wp_head', array($this, 'enqueue_public_form_styles'), 99); } // There is no shortcode in there, so override remove_filter('the_content', 'wpautop'); } elseif (membership_is_subscription_page($post->ID, false)) { // Handle any updates passed $page = isset($_REQUEST['action']) ? addslashes($_REQUEST['action']) : ''; if (empty($page)) { $page = 'renewform'; } if ($page == 'subscriptionsignup') { if (is_user_logged_in()) { $member = current_member(); list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']); if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) { $gateway = $_POST['gateway']; // Join the new subscription $member->create_subscription($sub_id, $gateway); do_action('membership_payment_subscr_signup', $user_id, $sub_id); // Timestamp the update update_user_meta($user_id, '_membership_last_upgraded', time()); // Added another redirect to the same url because the show_no_access filters // have already run on the "parse_request" action (Cole) wp_redirect(M_get_subscription_permalink()); exit; } } else { // check if a custom is posted and of so then process the user if (isset($_POST['custom'])) { list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']); if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) { $gateway = $_POST['gateway']; // Join the new subscription $member = Membership_Plugin::factory()->get_member($user_id); $member->create_subscription($sub_id, $gateway); do_action('membership_payment_subscr_signup', $user_id, $sub_id); // Timestamp the update update_user_meta($user_id, '_membership_last_upgraded', time()); // Added another redirect to the same url because the show_no_access filters // have already run on the "parse_request" action (Cole) wp_redirect(M_get_subscription_permalink()); exit; } } } } // account page - check if page contains a shortcode if (strstr($post->post_content, '[upgradeform]') !== false || strstr($post->post_content, '[renewform]') !== false) { // There is content in there with the shortcode so just return it if (!current_theme_supports('membership_subscription_form')) { $this->enqueue_subscription_scripts(); } return $posts; } // account page found - add in the styles if (!current_theme_supports('membership_account_form')) { $this->enqueue_subscription_scripts(); } // There is no shortcode in there, so override remove_filter('the_content', 'wpautop'); } elseif (membership_is_protected_page($post->ID, false)) { // no access page - we must return the content entered by the user so just return it return $posts; } elseif (membership_is_welcome_page($post->ID, false)) { // Registration complete page // Handle any updates passed $page = isset($_REQUEST['action']) && !empty($_REQUEST['action']) ? addslashes($_REQUEST['action']) : 'renewform'; if ($page == 'subscriptionsignup') { if (is_user_logged_in() && isset($_POST['custom'])) { list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']); if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) { $member = Membership_Plugin::factory()->get_member($user_id); $member->create_subscription($sub_id, $_POST['gateway']); do_action('membership_payment_subscr_signup', $user_id, $sub_id); // Timestamp the update update_user_meta($user_id, '_membership_last_upgraded', time()); // Added another redirect to the same url because the show_no_access filters // have already run on the "parse_request" action (Cole) wp_redirect(M_get_returnurl_permalink()); exit; } } else { // check if a custom is posted and of so then process the user if (isset($_POST['custom'])) { list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']); if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) { $member = Membership_Plugin::factory()->get_member($user_id); $member->create_subscription($sub_id, $_POST['gateway']); do_action('membership_payment_subscr_signup', $user_id, $sub_id); // Timestamp the update update_user_meta($user_id, '_membership_last_upgraded', time()); // Added another redirect to the same url because the show_no_access filters // have already run on the "parse_request" action (Cole) wp_redirect(M_get_returnurl_permalink()); exit; } } } } return $posts; } // If nothing else is hit, just return the content return $posts; }
function current_user_on_subscription($sub_id) { $member = current_member(); if (!empty($member)) { return $member->on_sub($sub_id); } else { return false; } }