/** * Update lead status of the specified payment * * @param Pronamic_Pay_Payment $payment */ public static function status_update(Pronamic_Pay_Payment $payment, $can_redirect = false) { $status = $payment->get_status(); $url = M_get_returnurl_permalink(); switch ($status) { case Pronamic_WP_Pay_Statuses::SUCCESS: $url = M_get_registrationcompleted_permalink(); break; } if ($url && $can_redirect) { wp_redirect($url, 303); exit; } }
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 single_free_button($pricing, $subscription, $user_id, $norepeat = false) { global $M_options; if (empty($M_options['paymentcurrency'])) { $M_options['paymentcurrency'] = 'USD'; } $form = ''; $form .= '<form action="' . M_get_returnurl_permalink() . '" method="post">'; $form .= wp_nonce_field('free-sub_' . $subscription->sub_id(), "_wpnonce", true, false); $form .= "<input type='hidden' name='gateway' value='" . $this->gateway . "' />"; $form .= '<input type="hidden" name="action" value="subscriptionsignup" />'; $form .= '<input type="hidden" name="custom" value="' . $this->build_custom($user_id, $subscription->id, '0') . '">'; $button = get_option($this->gateway . "_payment_button", 'https://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif'); $form .= '<input type="image" name="submit" border="0" src="' . $button . '" alt="PayPal - The safer, easier way to pay online">'; $form .= '</form>'; return $form; }
function single_free_button($pricing, $subscription, $user_id, $norepeat = false) { global $M_options; if (empty($M_options['paymentcurrency'])) { $M_options['paymentcurrency'] = 'USD'; } $form = ''; $coupon = membership_get_current_coupon(); $form .= '<form action="' . M_get_returnurl_permalink() . '" method="post" id="signup-form">'; $form .= wp_nonce_field('free-sub_' . $subscription->sub_id(), "_wpnonce", true, false); $form .= "<input type='hidden' name='gateway' value='" . $this->gateway . "' id='subscription_gateway' />"; $form .= '<input type="hidden" name="action" value="subscriptionsignup" />'; $form .= '<input type="hidden" name="custom" value="' . $this->build_custom($user_id, $subscription->id, '0') . '">'; $form .= '<input type="hidden" name="subscription" id="subscription_id" value="' . $subscription->id . '" />'; $form .= '<input type="hidden" name="user" id="subscription_user_id" value="' . $user_id . '" />'; $button = get_option($this->gateway . "_payment_button", ''); if (empty($button)) { $form .= '<input type="submit" class="button ' . apply_filters('membership_subscription_button_color', '') . '" value="' . __('Sign Up', 'membership') . '" />'; } else { $form .= '<input type="image" name="submit" border="0" src="' . $button . '" alt="PayPal - The safer, easier way to pay online">'; } $form .= '<input type="hidden" name="coupon_code" id="subscription_coupon_code" value="' . (!empty($coupon) ? $coupon->get_coupon_code() : '') . '" />'; $form .= '</form>'; return $form; }
public function get_normal_return_url() { if (Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Extension::is_membership2()) { return esc_url_raw(add_query_arg(array('ms_relationship_id' => $this->subscription->id), MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REGISTER, false))); } return M_get_returnurl_permalink(); }
function complex_upgrade_button($pricing, $subscription, $user_id, $fromsub_id = false) { global $M_options; if (empty($M_options['paymentcurrency'])) { $M_options['paymentcurrency'] = 'USD'; } $form = ''; if (get_option($this->gateway . "_paypal_status") == 'live') { $form .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">'; } else { $form .= '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">'; } $form .= '<input type="hidden" name="business" value="' . esc_attr(get_option($this->gateway . "_paypal_email")) . '">'; $form .= '<input type="hidden" name="cmd" value="_xclick-subscriptions">'; $form .= '<input type="hidden" name="item_name" value="' . $subscription->sub_name() . '">'; $form .= '<input type="hidden" name="item_number" value="' . $subscription->sub_id() . '">'; $form .= '<input type="hidden" name="currency_code" value="' . $M_options['paymentcurrency'] . '">'; // complex bits here $count = 1; $ff = array(); foreach ((array) $pricing as $key => $price) { switch ($price['type']) { case 'finite': if (empty($price['amount'])) { $price['amount'] = '0'; } if ($count < 3) { $ff['a' . $count] = apply_filters('membership_amount_' . $M_options['paymentcurrency'], number_format($price['amount'], 2, '.', '')); $ff['p' . $count] = $price['period']; $ff['t' . $count] = strtoupper($price['unit']); } else { // Or last finite is going to be the end of the subscription payments $ff['a3'] = number_format($price['amount'], 2, '.', ''); $ff['p3'] = $price['period']; $ff['t3'] = strtoupper($price['unit']); $ff['src'] = '0'; } $count++; break; case 'indefinite': if (empty($price['amount'])) { $price['amount'] = '0'; } if ($price['amount'] == '0') { // The indefinite rule is free, we need to move any previous // steps up to this one as we can't have a free a3 if (isset($ff['a2']) && $ff['a2'] != '0.00') { // we have some other earlier rule so move it up $ff['a3'] = $ff['a2']; $ff['p3'] = $ff['p2']; $ff['t3'] = $ff['t2']; unset($ff['a2']); unset($ff['p2']); unset($ff['t2']); $ff['src'] = '0'; } elseif (isset($ff['a1']) && $ff['a1'] != '0.00') { $ff['a3'] = $ff['a1']; $ff['p3'] = $ff['p1']; $ff['t3'] = $ff['t1']; unset($ff['a1']); unset($ff['p1']); unset($ff['t1']); $ff['src'] = '0'; } } else { $ff['a3'] = apply_filters('membership_amount_' . $M_options['paymentcurrency'], number_format($price['amount'], 2, '.', '')); $ff['p3'] = 1; $ff['t3'] = 'Y'; $ff['src'] = '0'; } break; case 'serial': if (empty($price['amount'])) { $price['amount'] = '0'; } if ($price['amount'] == '0') { // The serial rule is free, we need to move any previous // steps up to this one as we can't have a free a3 if (isset($ff['a2']) && $ff['a2'] != '0.00') { // we have some other earlier rule so move it up $ff['a3'] = $ff['a2']; $ff['p3'] = $ff['p2']; $ff['t3'] = $ff['t2']; unset($ff['a2']); unset($ff['p2']); unset($ff['t2']); $ff['src'] = '1'; } elseif (isset($ff['a1']) && $ff['a1'] != '0.00') { $ff['a3'] = $ff['a1']; $ff['p3'] = $ff['p1']; $ff['t3'] = $ff['t1']; unset($ff['a1']); unset($ff['p1']); unset($ff['t1']); $ff['src'] = '1'; } } else { $ff['a3'] = apply_filters('membership_amount_' . $M_options['paymentcurrency'], number_format($price['amount'], 2, '.', '')); $ff['p3'] = $price['period']; $ff['t3'] = strtoupper($price['unit']); $ff['src'] = '1'; } break; } } if (!empty($ff)) { foreach ($ff as $key => $value) { $form .= '<input type="hidden" name="' . $key . '" value="' . $value . '">'; } } $form .= '<input type="hidden" name="custom" value="' . $this->build_custom($user_id, $subscription->id, $ff['a3'], $fromsub_id) . '">'; // Remainder of the easy bits $form .= '<input type="hidden" name="return" value="' . apply_filters('membership_return_url_' . $this->gateway, M_get_returnurl_permalink()) . '">'; $form .= '<input type="hidden" name="cancel_return" value="' . apply_filters('membership_cancel_url_' . $this->gateway, M_get_subscription_permalink()) . '">'; $form .= '<input type="hidden" name="lc" value="' . esc_attr(get_option($this->gateway . "_paypal_site")) . '">'; $form .= '<input type="hidden" name="notify_url" value="' . trailingslashit(get_option('home')) . 'paymentreturn/' . esc_attr($this->gateway) . '">'; $form .= '<input type="hidden" name="modify" value="2">'; $button = get_option($this->gateway . "_paypal_upgrade_button", 'https://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif'); $form .= '<!-- Display the payment button. --> <input type="image" name="submit" border="0" src="' . $button . '" alt="PayPal - The safer, easier way to pay online">'; $form .= '<img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" >'; $form .= '</form>'; return $form; }
/** * * @access public * @global string $M_options * @param type $pricing * @param type $subscription * @param type $user_id * @param type $sublevel * @return string */ public function single_free_button($pricing, $subscription, $user_id, $sublevel = 0) { global $M_options; if (empty($M_options['paymentcurrency'])) { $M_options['paymentcurrency'] = 'USD'; } $form = '<form action="' . M_get_returnurl_permalink() . '" method="post">'; $form .= '<input type="hidden" name="custom" value="' . $this->build_custom($user_id, $subscription->id, '0', $sublevel) . '">'; if ($sublevel == 1) { $form .= '<input type="hidden" name="action" value="subscriptionsignup" />'; $form .= wp_nonce_field('free-sub_' . $subscription->sub_id(), "_wpnonce", false, false); $form .= "<input type='hidden' name='gateway' value='" . $this->gateway . "' />"; $button = get_option($this->gateway . "_payment_button", ''); if (empty($button)) { $form .= '<input type="submit" class="button ' . apply_filters('membership_subscription_button_color', '') . '" value="' . __('Sign Up', 'membership') . '" />'; } else { $form .= '<input type="image" name="submit" border="0" src="' . $button . '" alt="PayPal - The safer, easier way to pay online">'; } } else { $form .= wp_nonce_field('renew-sub_' . $subscription->sub_id(), "_wpnonce", false, false); //$form .= wp_nonce_field('free-sub_' . $subscription->sub_id(), "_wpnonce", false, false); $form .= "<input type='hidden' name='action' value='subscriptionsignup' />"; $form .= "<input type='hidden' name='gateway' value='" . $this->gateway . "' />"; $form .= "<input type='hidden' name='subscription' value='" . $subscription->sub_id() . "' />"; $form .= "<input type='hidden' name='user' value='" . $user_id . "' />"; $form .= "<input type='hidden' name='level' value='" . $sublevel . "' />"; $button = get_option($this->gateway . "_payment_button", ''); if (empty($button)) { $form .= '<input type="submit" class="button ' . apply_filters('membership_subscription_button_color', '') . '" value="' . __('Sign Up', 'membership') . '" />'; } else { $form .= '<input type="image" name="submit" border="0" src="' . $button . '" alt="PayPal - The safer, easier way to pay online">'; } } $form .= '</form>'; return $form; }
function single_button($pricing, $subscription, $user_id) { global $M_options; if (class_exists('Membership_Gateway')) { // It is possible there is free trial set before the actual subscription takes place, // so we're going to find the first price that's >0 and use that as our price if ($pricing[0]['amount'] < 1) { foreach ($pricing as $price_obj) { if ($price_obj['amount'] >= 1) { $final_price = $price_obj['amount']; break; } } } else { $final_price = $pricing[0]['amount']; } } if (empty($M_options['paymentcurrency'])) { $M_options['paymentcurrency'] = 'USD'; } $form = ''; $bpformURL = get_option($this->gateway . "_bitpay_formurl", "https://your_website_url/wp-content/plugins/bitpay-form-helper/form.php"); $form .= '<form id="bitpay-form" action="' . $bpformURL . '" method="post">'; $form .= '<input type="hidden" name="orderID" value="' . $subscription->id . '">'; $form .= '<input type="hidden" name="itemCode" value="' . $subscription->sub_id() . '">'; $form .= '<input type="hidden" name="itemDesc" value="' . $subscription->sub_name() . '">'; $form .= '<input type="hidden" name="price" value="' . number_format($pricing[0]['amount'], 2) . '">'; $form .= '<input type="hidden" name="transactionSpeed" value="' . get_option($this->gateway . "_transact_speed") . '">'; $form .= '<input type="hidden" name="currency" value="' . $M_options['paymentcurrency'] . '">'; $form .= '<input type="hidden" name="rcla" value="' . base64_encode(get_option($this->gateway . "_api_key")) . '">'; $form .= '<input type="hidden" name="posData" value="' . $this->build_custom($user_id, $subscription->id, number_format($pricing[0]['amount'], 2)) . '">'; $form .= '<input type="hidden" name="notificationURL" value="' . trailingslashit(get_option('home')) . 'paymentreturn/' . esc_attr($this->gateway) . '">'; $form .= '<input type="hidden" name="redirectURL" value="' . apply_filters('membership_return_url_' . $this->gateway, M_get_returnurl_permalink()) . '">'; $form .= '<input type="hidden" name="network" value="' . get_option($this->gateway . "_network") . '">'; $button = get_option($this->gateway . "_bitpay_button", 'https://button_URL_goes_here'); $form .= '<input type="image" name="submit" border="0" src="' . $button . '" alt="Bitcoin payments via BitPay">'; $form .= '</form>'; return $form; }
public function get_normal_return_url() { return M_get_returnurl_permalink(); }
function common_button_fields($subscription, $norepeat = false) { global $M_options; $form = ''; // the charset to use $form .= '<input type="hidden" name="charset" value="utf-8">'; // the merchant account id OR email address $form .= '<input type="hidden" name="business" value="' . esc_attr(get_option($this->gateway . "_paypal_email")) . '">'; if ($norepeat) { // tell PayPal we're using a Buy Now button $form .= '<input type="hidden" name="cmd" value="_xclick">'; } else { // tell PayPal we're using subscription button $form .= '<input type="hidden" name="cmd" value="_xclick-subscriptions">'; } // our Incsub BN code $form .= '<input type="hidden" name="bn" value="incsub_SP">'; // the name of the subscription $form .= '<input type="hidden" name="item_name" value="' . $subscription->sub_name() . '">'; // the subscription id $form .= '<input type="hidden" name="item_number" value="' . $subscription->sub_id() . '">'; // the currency to use $form .= '<input type="hidden" name="currency_code" value="' . $M_options['paymentcurrency'] . '">'; // what url to go to after payment has been completed $form .= '<input type="hidden" name="return" value="' . apply_filters('membership_return_url_' . $this->gateway, M_get_returnurl_permalink()) . '">'; // what url to go to when user hits cancel $form .= '<input type="hidden" name="cancel_return" value="' . apply_filters('membership_cancel_url_' . $this->gateway, M_get_subscription_permalink()) . '">'; // the locale $form .= '<input type="hidden" name="lc" value="' . esc_attr(get_option($this->gateway . "_paypal_site")) . '">'; // where IPN webhooks will be sent to $form .= '<input type="hidden" name="notify_url" value="' . apply_filters('membership_notify_url_' . $this->gateway, home_url('paymentreturn/' . esc_attr($this->gateway))) . '">'; // don't allow notes to entered $form .= '<input type="hidden" name="no_note" value="1" />'; // don't ask for a shipping address $form .= '<input type="hidden" name="no_shipping" value="1" />'; return apply_filters('membership_' . $this->gateway . '_common_button_fields', $form); }
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; }
/** * Payment redirect URL filter. * * @param string $url * @param Pronamic_WP_Pay_Payment $payment * @return string */ public static function redirect_url($url, $payment) { // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-pages.php#L492-L530 if (Pronamic_WP_Pay_Class::method_exists('MS_Model_Pages', 'get_page_url')) { // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-pages.php#L44-L55 $url = MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REGISTER); } elseif (function_exists('M_get_returnurl_permalink')) { // @see https://github.com/wp-plugins/membership/blob/3.4.4.3/membershipincludes/includes/functions.php#L598-L622 $url = M_get_returnurl_permalink(); } switch ($payment->get_status()) { case Pronamic_WP_Pay_Statuses::SUCCESS: // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-pages.php#L492-L530 if (Pronamic_WP_Pay_Class::method_exists('MS_Model_Pages', 'get_page_url')) { $invoice_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_invoice_id', true); $invoice = MS_Factory::load('MS_Model_Invoice', $invoice_id); $subscription = $invoice->get_subscription(); // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-pages.php#L44-L55 $url = add_query_arg('ms_relationship_id', $subscription->id, MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REG_COMPLETE)); } elseif (function_exists('M_get_registrationcompleted_permalink')) { // @see https://github.com/wp-plugins/membership/blob/3.4.4.3/membershipincludes/includes/functions.php#L576-L598 $url = M_get_registrationcompleted_permalink(); } break; } return $url; }