latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Auto-Return template, Upgrade emails, cache

Home Forums Community Forum Auto-Return template, Upgrade emails, cache

This topic contains 5 replies, has 2 voices. Last updated by  Cristián Lávaque 4 years, 2 months ago.

Topic Author Topic
Posted: Saturday Oct 20th, 2012 at 2:01 pm #29164

I’m waving my white flag here and asking for some help :)

–ISSUES–

Scenario… After a successful paypal payment the user is auto-returned to the s2members “Auto-Return Page Template” which has my “optional css customizations”.

ISSUE1. It’s not using custom template paypal-return.php. EDIT ISSUE FIXED – this was resolved by moving the file from the child theme directory to the main template directory.

ISSUE2. Although the Member is updated in the database immediately after making the paypal purchase, the user is not recognized as a Level1 member unless they refresh this auto-return url page.
I believe this is due to the site caching the user as unpaid.
EDIT – added the wp_s2member_paid_registration_times to the “ignored query strings” on database caching, but it hasn’t changed anything.
TEMP FIX – Direct users on from the auto-return url to a page open to the public that contains a manual php to check user level from the database. This seemed to resolve the caching issue, but isn’t really ideal.
auto-return URL –

http://mysite.com/?s2member_paypal_return=1&s2member_paypal_return_tra=fnIyOmk0Z3JRQ0hoRE5nbjQxREdLOFhrY0hBdTZVc29jMkVaOmQwYTk5NjgxZDk3MDA4MzM1NGRhNzc3Zjk5MmU5ZWU4fNpBuvirBDEKWegO6I5PMwK8yrFBXXtSri-c0CrerV2GgzlgS45CH-UZC0Z_TYnediDB0ViouOoMe0acWPgWTm3_630D8oLngxd0TwD974Y0Co3o5Lh6lgqdtPw4mbs4bfm4_HaTssewgDabQqmFVaXuPaV5_1w5w46mlz3Mw67zXv0E6H-JikcR4FxgkCJHm7upLGBF2Mujy4yjJlXnodu9Heg3EmKTvjWr9AOuzSIIPhzG-msep0LiIfVFlBbwyiinvgNRhEQgv9gbg08SqGcwfERIPenKcAIWe2XwpZ6UV4EPsE8Soqc78zKtS1CeFhe9gpKv0wk1lM7p6W686D4JlPgLVAIvKzknxkS8lN9M2X5sNMpB9qXd_HoGg4u9mw

ISSUE3. The paypal user receives the s2member generic email (not my custom email in the s2-hacks.php) and nothing at all to the wp site member.
EDIT – after moving s2-hacks.php to a “/mu-plugins/” directory, the customized email for the paypal email worked , but only after including wp-config.php to the file. still no emails sending with the wp_mail function inside the function my_s2_modification_msg. (updated current version of s2-hacks.php below)
EDIT – previous email with s2-hacks.php in the “/plugins/” quoted as follows… (obviously it just couldn’t find the s2-hacks.php file)

Thank you! You’ve been updated to:
FREE for 6 months, then $2 yearly (recurring for ongoing access).

Please log back in now.
http://mysite.com/wp-login.php

–SPECS–

wp 3.4.2
s2member Version 120703 + s2Member Pro v120703

All customers already have level0 free accounts before paying for Level1 access.

Server Check… Got the test email, success.

w3total Cache Options…
turned off Object Caching on w3totalcache
EDIT – added wp_s2member_paid_registration_times to “ignored query strings” on Database caching.

PayPal Options…
PayPal® Pro Forms / Recurring Profile Behavior: Real-Time/Direct Pay

Automatic EOT Behavior…

Auto-Return…
1. “Auto-Return Page Template” with “optional css customizations”.
2 . /wp-contents/themes/mychildtheme/paypal-return.php custom template inside my active themes (which is a child theme) root folder. EDIT – moved to /wp-contents/themes/maintheme/paypal-return.php

s2-Hacks…
/wp-content/plugins/s2-Hacks.php (EDIT – moved file to /wp-content/mu-plugins/s2-Hacks.php) contains code to generate a custom email when members are upgraded. In the code we have it set to find the user by the $vars[“user_id”] then email the site member, the paypal payer, and site support via wp_mail.
per http://www.primothemes.com/forums/viewtopic.php?f=4&t=10368#p33365

<?php
/*
s2member hacks for mysite.com

more info about the mu-plugins directory http://codex.wordpress.org/Must_Use_Plugins

Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php

per: http://www.primothemes.com/forums/viewtopic.php?f=4&t=10368#p33365 and http://www.s2member.com/kb/hacking-s2member/

		# Optional. s2Member® passes you an array of defined variables.
		# print_r($vars); # Would give you a list of defined variables.
		# These are PHP variables defined within the scope of the Hook,
		# at the precise point in which the Hook is fired by s2Member®.
 
		# $vars["__refs"] are also included (with some Hooks).
		# These are internal PHP variable references (very useful).
		# To learn all about references, please see PHP documentation:
		# http://www.php.net/manual/en/language.references.pass.php
*/


//Include WordPress
include('/home/content/41/9502741/html/mysite/wp-config.php');
define('WP_USE_THEMES', false);
//require('/home/content/41/9502741/html/mysite/wp-blog-header.php'); <--  caused a fatal error.
require_once('/home/content/41/9502741/html/mysite/wp-load.php');


//customize the member upgrade/downgrade email since our members are already free members when they pay for membership.
add_filter( "ws_plugin__s2member_modification_email_sbj", "my_s2_modification_sbj", 10, 2 );
function my_s2_modification_sbj( $s2member_default_sbj, $vars = array() ){
		if( isset($vars["user_id"]) ){ 
			$wp_userdata = get_userdata($vars["user_id"]);
			$users_name = $wp_userdata->display_name;
			//the email subject:
			return $users_name." is ready to go on mysite!";
		} else {
			//the email subject:
			return "Your mysite Membership is ready!";
   		}
}//end function my_s2_modification_sbj( $s2member_default_sbj, $vars = array() )

	
add_filter( "ws_plugin__s2member_modification_email_msg", "my_s2_modification_msg", 10, 2 );
function my_s2_modification_msg( $s2member_default_msg, $vars = array() ){
		global $homepage_url;
		//the email message:
		//before hacks... return "Thank you! You've been updated to:\n" . $vars["paypal"]["item_name"] . "\n\nPlease log back in now:\n" . wp_login_url ();
		
		//set the members email and the site notification to send html
		$headers = 'From: mysite <info@mysite.com>' . "\r\n" . 
			//'Reply-To: ' . $from. "\r\n" . 
			'Content-Type: text/html'; //<-- adding html email ability	

		if( isset($vars["user_id"]) ){ 
			$wp_userdata = get_userdata($vars["user_id"]);
			
			$users_email = $wp_userdata->user_email;
			$users_name = $wp_userdata->display_name;
			
			if( isset($users_email) ){
				//Build the user a message
				$users_subject = $users_name.'! Your mysite membership is complete';
				
				$users_message = '<span style="font-family: Verdana, Geneva, sans-serif;">';
				$users_message .= 'Thanks '.$users_name.'! Your mysite membership is complete.<br>';
				$users_message .= '<br>';
				$users_message .= '<h4>Go fill out your profile and reply to some posts!/h4><br>';
				$users_message .= $homepage_url.'/profile/<br>';
				$users_message .= '<a href="http://mysite.com">mysite.com</a>!<br><a href="http://mysite.com"><img src="http://mysite.com/wp-content/themes/mysite/images/mysite_new_posts.jpg" border="0px"></a>';
				$users_message .= '<br>';
				$users_message .= '<br>';
				$users_message .= 'mysite Member\'s Info...<br>';
				$users_message .= ' Name: '.$users_name.'<br>';
				$users_message .= ' ID: '.$vars['user_id'].'<br>';
				$users_message .= ' email: '.$users_email.'<br>';
				$users_message .= ' Payment Subscription# '.$vars['paypal']['subscr_id'].' '.$vars['paypal']['item_name'].'<br>';
				$users_message .= '<br>';
				$users_message .= ' If you have any trouble, please feel free to reply or forward this email to info@mysite.com for help.';
				$users_message .= '</span>';
			
				// SEND the mysite Member an email...
				wp_mail($users_email, $users_subject, $user_message, $headers);	
			}//END if( isset($users_email) ){
		}//END  if( isset($vars["user_id"]) ){ 
		
		//build mysite a notification
		$print_vars = print_r($vars, TRUE);
		
		$mysite_subject = 'New mysite Member: '.$users_name;

		$mysite_message = "Member Name:".$vars["user_id"]."<br>";
		$mysite_message .= "mysite ID:".$users_name."<br>";
		$mysite_message .= "Users Email:".$users_email."<br>";
		$mysite_message .= "<br>";
		$mysite_message .= "Payment Subscription ID:".$vars["paypal"]["subscr_id"]."<br>";
		$mysite_message .= "Item:".$vars["paypal"]["item_name"]."<br>";
		$mysite_message .= "PayPal Email:".$vars["paypal"]["payer_email"]."<br>";
		$mysite_message .= "<br>";
		$mysite_message .= "All $vars: ".$print_vars;

		// Send email to mysite - assumes $to, $subject, $message have already been defined earlier...
		wp_mail('members@mysite.com', $mysite_subject, $mysite_message, $headers);
		
		/*remove did not work... 
			$paypal_users_message = "Thanks ".$users_name."! Your mysite membership is complete.";
			$paypal_users_message .= "";
			$paypal_users_message .= "Go fill out your profile and reply to some posts!";
			$paypal_users_message .= $homepage_url."/profile/";
			$paypal_users_message .= "";	
			$paypal_users_message .= "Subscription# ".$vars["paypal"]["subscr_id"];
			$paypal_users_message .= "mysite Member: ".$users_name;
			$paypal_users_message .= "mysite ID: ".$vars["user_id"];
			if( isset($users_email) ){ $paypal_users_message .= $users_email; }
			$paypal_users_message .= "For: ".$vars["paypal"]["item_name"];
			$paypal_users_message .= "";	 
			$paypal_users_message .= "If you have any trouble, please feel free to reply to this email for help.";
			$paypal_users_message .= "info@mysite.com";
			$paypal_users_message .= "";
			//remove did not work... $paypal_users_message .= "Testing all $vars: ".$print_vars;
		*/
		
		//Send the Paypal user an email...
		//before hacks... return "Thank you! You've been updated to:\n" . $vars["paypal"]["item_name"] . "\n\nPlease log back in now:\n" . wp_login_url ();
		
		/*NOTE these lines were tried and did not send an email at all as return: 
			"Testing all $vars: ".$print_vars;
			$paypal_users_message (with each line as $paypal_users_message .= "all quotes "and no apostrophies" as noted above"
		*/
		
		/**the following return results in a successful email to the paypay email**
		**************************************************************************
			Thanks Mira Concepts! Your mysite membership is complete.
				
			Go fill out your profile and reply to some posts!
			http://mysite.com/profile/
						
			mysite Member's Info...
			 Name: Mira Concepts
			 ID: 82
			 email: mira.testing@mysite.com
			 Payment Subscription# I-Y5RPK0KYCNB1 mysite.com FREE for 6 months, then $2 yearly (recurring for ongoing access).

			If you have any trouble, please feel free to reply to this email for help.
			info@mysite.com
		*/
		return 	"Thanks ".$users_name."! Your mysite membership is complete.\n\nGo fill out your profile and reply to some posts!\n".$homepage_url."/profile/\n\n\nmysite Member's Info...\n Name: ".$users_name."\n ID: ".$vars["user_id"]." email: ".$users_email."\n\n Payment Subscription# ".$vars["paypal"]["subscr_id"]." ".$vars["paypal"]["item_name"]."\n\nIf you have any trouble, please feel free to reply or forward this email to info@mysite.com for help.";	
		
}//ENd function my_s2_modification_msg( $s2member_default_msg, $vars = array() )
?>

Button in question...
Regular Paypal Button generated by s2member and added via a wp page with shortcode. “6month free trial, then $2 yearly for ongoing access.”

[s2Member-PayPal-Button level="1" ccaps="" desc="FREE for 6 months, then $2 yearly (recurring for ongoing access)." ps="mysite" lc="" cc="USD" dg="0" ns="1" custom="mysite.com" ta="0" tp="6" tt="M" ra="2.00" rp="1" rt="Y" rr="1" rrt="" rra="1" image="http://mysite.com/buywithpaypal.jpg" output="button" success=""/]

PayPal-rtn.log…

PHP v5.3.14 :: WordPress® v3.4.2 :: s2Member® v120703 :: s2Member® Pro v120703
Memory 7.53 MB :: Real Memory 7.75 MB :: Peak Memory 7.61 MB :: Real Peak Memory 7.75 MB
mysite.com/?s2member_paypal_return=1&s2member_paypal_return_tra=fnIyOmk0Z3JRQ0hoRE5nbjQxREdLOFhrY0hBdTZVc29jMkVaOmQwYTk5NjgxZDk3MDA4MzM1NGRhNzc3Zjk5MmU5ZWU4fNpBuvirBDEKWegO6I5PMwK8yrFBXXtSri-c0CrerV2GgzlgS45CH-UZC0Z_TYnediDB0ViouOoMe0acWPgWTm3_630D8oLngxd0TwD974Y0Co3o5Lh6lgqdtPw4mbs4bfm4_HaTssewgDabQqmFVaXuPaV5_1w5w46mlz3Mw67zXv0E6H-JikcR4FxgkCJHm7upLGBF2Mujy4yjJlXnodu9Heg3EmKTvjWr9AOuzSIIPhzG-msep0LiIfVFlBbwyiinvgNRhEQgv9gbg08SqGcwfERIPenKcAIWe2XwpZ6UV4EPsE8Soqc78zKtS1CeFhe9gpKv0wk1lM7p6W686D4JlPgLVAIvKzknxkS8lN9M2X5sNMpB9qXd_HoGg4u9mw
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
array (
  'subscr_gateway' => 'paypal',
  's2member_log' => 
  array (
    0 => 'No Return-Data. Customer must wait for Email Confirmation.',
    1 => 'Redirecting Customer to the Home Page. Customer must wait for Email Confirmation.',
    2 => 'Note. This can sometimes happen when/if you are offering a free Trial Period. There are times when a Payment Gateway will NOT supply s2Member with any data immediately after checkout. When/if this happens, s2Member must process the transaction via IPN only ( i.e. behind-the-scene ), and the Customer must wait for Email Confirmation in these cases.',
    3 => 'array (
  \'s2member_paypal_return\' => \'1\',
  \'s2member_paypal_return_tra\' => \'fnIyOmk0Z3JRQ0hoRE5nbjQxREdLOFhrY0hBdTZVc29jMkVaOmQwYTk5NjgxZDk3MDA4MzM1NGRhNzc3Zjk5MmU5ZWU4fNpBuvirBDEKWegO6I5PMwK8yrFBXXtSri-c0CrerV2GgzlgS45CH-UZC0Z_TYnediDB0ViouOoMe0acWPgWTm3_630D8oLngxd0TwD974Y0Co3o5Lh6lgqdtPw4mbs4bfm4_HaTssewgDabQqmFVaXuPaV5_1w5w46mlz3Mw67zXv0E6H-JikcR4FxgkCJHm7upLGBF2Mujy4yjJlXnodu9Heg3EmKTvjWr9AOuzSIIPhzG-msep0LiIfVFlBbwyiinvgNRhEQgv9gbg08SqGcwfERIPenKcAIWe2XwpZ6UV4EPsE8Soqc78zKtS1CeFhe9gpKv0wk1lM7p6W686D4JlPgLVAIvKzknxkS8lN9M2X5sNMpB9qXd_HoGg4u9mw\',
)',
  ),
  's2member_paypal_return_tra' => 'fnIyOmk0Z3JRQ0hoRE5nbjQxREdLOFhrY0hBdTZVc29jMkVaOmQwYTk5NjgxZDk3MDA4MzM1NGRhNzc3Zjk5MmU5ZWU4fNpBuvirBDEKWegO6I5PMwK8yrFBXXtSri-c0CrerV2GgzlgS45CH-UZC0Z_TYnediDB0ViouOoMe0acWPgWTm3_630D8oLngxd0TwD974Y0Co3o5Lh6lgqdtPw4mbs4bfm4_HaTssewgDabQqmFVaXuPaV5_1w5w46mlz3Mw67zXv0E6H-JikcR4FxgkCJHm7upLGBF2Mujy4yjJlXnodu9Heg3EmKTvjWr9AOuzSIIPhzG-msep0LiIfVFlBbwyiinvgNRhEQgv9gbg08SqGcwfERIPenKcAIWe2XwpZ6UV4EPsE8Soqc78zKtS1CeFhe9gpKv0wk1lM7p6W686D4JlPgLVAIvKzknxkS8lN9M2X5sNMpB9qXd_HoGg4u9mw',
)

paypal-payflow-api…

PHP v5.3.14 :: WordPress® v3.4.2 :: s2Member® v120703 :: s2Member® Pro v120703
Memory 6.59 MB :: Real Memory 7.00 MB :: Peak Memory 6.61 MB :: Real Peak Memory 7.00 MB
mysite.com/wp-cron.php?doing_wp_cron=1350750084.5887689590454101562500
User-Agent: WordPress/3.4.2; http://mysite.com
-------- Input vars: ( Sat Oct 20, 2012 4:22:43 pm UTC ) --------
array (
  'TRXTYPE' => 'R',
  'ACTION' => 'I',
  'TENDER' => 'P',
  'ORIGPROFILEID' => 'I-M10REMBL4D55',
  'VERBOSITY' => 'HIGH',
  'USER' => 'info_api1.mysite.net',
  'PARTNER' => 'PayPal',
  'VENDOR' => '*************',
  'PWD' => '*************',
)
-------- Output string/vars: ( Sat Oct 20, 2012 4:22:44 pm UTC ) --------
RESULT=1&RESPMSG=User authentication failed
array (
  'RESULT' => '1',
  'RESPMSG' => 'User authentication failed',
  '__error' => 'Error #1. User authentication failed.',
)

paypal-ipn….

PHP v5.3.14 :: WordPress® v3.4.2 :: s2Member® v120703 :: s2Member® Pro v120703
Memory 22.04 MB :: Real Memory 22.50 MB :: Peak Memory 22.08 MB :: Real Peak Memory 22.50 MB
mysite.com/?s2member_paypal_notify=1
User-Agent: 
array (
  'invoice' => '5082ccc52097c~98.92.215.165',
  'amount1' => '0.00',
  'amount3' => '2.00',
  'subscr_date' => '09:12:13 Oct 20, 2012 PDT',
  'payer_id' => '*************',
  'mc_amount1' => '0.00',
  'mc_amount3' => '2.00',
  'charset' => 'windows-1252',
  'first_name' => 'me',
  'option_selection1' => '57',
  'option_selection2' => '*************',
  'reattempt' => '1',
  'notify_version' => '3.7',
  'subscr_id' => 'I-M10REMBL4D55',
  'custom' => 'mysite.com',
  'payer_status' => 'verified',
  'business' => 'info@mysite.net',
  'verify_sign' => '*************',
  'payer_email' => 'me@mysite.com',
  'option_name1' => 'Referencing Customer ID',
  'option_name2' => 'Customer IP Address',
  'payer_business_name' => ''*************',',
  'last_name' => '*************',
  'receiver_email' => 'info@mysite.net',
  'recurring' => '2.00',
  'txn_type' => 'subscr_signup',
  'item_name' => 'FREE for 6 months, then $2 yearly (recurring for ongoing access).',
  'mc_currency' => 'USD',
  'item_number' => '1',
  'residence_country' => 'US',
  'period1' => '6 M',
  'period3' => '1 Y',
  'ipn_track_id' => '957a720f735c0',
  's2member_log' => 
  array (
    0 => 'IPN received on: Sat Oct 20, 2012 4:12:32 pm UTC',
    1 => 's2Member POST vars verified through a POST back to PayPal®.',
    2 => 's2Member originating domain ( `$_SERVER["HTTP_HOST"]` ) validated.',
    3 => 's2Member `txn_type` identified as ( `web_accept|subscr_signup` ).',
    4 => 's2Member `txn_type` identified as ( `web_accept|subscr_signup` ) w/ update vars.',
    5 => 's2Member Level/Capabilities updated w/ advanced update routines.',
    6 => 'Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.',
    7 => 'Storing IPN signup vars now. These are associated with a User\'s account record; for future reference.',
  ),
  'subscr_gateway' => 'paypal',
  'eotper' => NULL,
  'ccaps' => NULL,
  'level' => '1',
  'ip' => '*************',
  'initial_term' => '6 M',
  'initial' => '0.00',
  'regular' => '2.00',
  'regular_term' => '1 Y',
)
  • This topic was modified 4 years, 2 months ago by  Mira Concepts.
  • This topic was modified 4 years, 2 months ago by  Mira Concepts.
  • This topic was modified 4 years, 2 months ago by  Mira Concepts. Reason: added wp_s2member_paid_registration_times to "ignored query strings" on database cache
  • This topic was modified 4 years, 2 months ago by  Mira Concepts. Reason: moved s2-hacks.php to the "mu-plugins" directory per http://www.s2member.com/kb/hacking-s2member/
  • This topic was modified 4 years, 2 months ago by  Mira Concepts. Reason: custom template paypal-return.php issue was resolved by moving the file from the child theme directory to the main template directory

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Monday Oct 22nd, 2012 at 8:39 am #29241

Hi Mira.

Thank you so much for all the details you provided and having researched the solutions in the forums first. You seem to have done a great job so far.

ISSUE1. It’s not using custom template paypal-return.php. EDIT ISSUE FIXED – this was resolved by moving the file from the child theme directory to the main template directory.

Good. You can also use the [hilite mono]success[/hilite] attribute pointing to any normal WP page as the return page.
[hilite path]Dashboard -› s2Member® -› PayPal® Pro Forms -› Custom Return URLs Upon Success[/hilite]
[hilite path]Dashboard -› s2Member® -› PayPal® Buttons -› Shortcode Attributes -> success[/hilite]

w3total Cache Options…
turned off Object Caching on w3totalcache
EDIT – added wp_s2member_paid_registration_times to “ignored query strings” on Database caching.

I don’t remember having seen that come up with w3 Total Cache before, only Object Caching. I wonder if going through the custom return template has something to do. Do you have this problem with the regular return page or [hilite mono]success[/hilite] attribute?

Regular Paypal Button generated by s2member and added via a wp page with shortcode. “6month free trial, then $2 yearly for ongoing access.”

This seems fine, but I don’t get why you’re having a PayFlow API log generated if you’re using a PayPal Standard button.

Just to remove variables from the scenario, in order to simplify spotting what’s causing the trouble, could you deactivate the caching plugin temporarily and do another test transaction? 1 cent is fine. Also, remove the custom return template, and the custom confirmation email hack, please.

If some of the problems, or all, go away with those changes, you can bring back what you removed, but one by one, testing again after each.

Let me know how it goes!

Posted: Monday Oct 22nd, 2012 at 6:07 pm #29339

Hey thanks for the tips! okay tested things out the way you suggested and here are the results….

–test1–

w3totalcache turned off entirely
no paypal-return.php
no s2-hack.php
Button code:

[s2Member-PayPal-Button level="1" ccaps="" desc="FREE for 6 months, then $2 yearly (recurring for ongoing access)." ps="mysite" lc="" cc="USD" dg="0" ns="1" custom="mysite.com" ta="0" tp="6" tt="M" ra="2.00" rp="1" rt="Y" rr="1" rrt="" rra="1" image="http://mysite.com/buywithpaypal.jpg" output="button" /]

Auto return url takes you to the s2member page…

Thank you! ( you MUST check your email before proceeding ).

* Note: It can take ( up to 15 minutes ) for Email Confirmation with important details. If you don’t receive email confirmation in the next 15 minutes, please contact Support.
Back To Home Page

Button links to http://mysite.com/
Clicking the button takes you into the site just fine. no issues.

–test2–

w3totalcache turned off entirely
no paypal-return.php
no s2-hack.php
button shortcode with success url

[s2Member-PayPal-Button level="1" ccaps="" desc="FREE for 6 months, then $2 yearly (recurring for ongoing access)." ps="mysite" lc="" cc="USD" dg="0" ns="1" custom="mysite.com" ta="0" tp="6" tt="M" ra="2.00" rp="1" rt="Y" rr="1" rrt="" rra="1" image="http://mysite.com/buywithpaypal.jpg" output="button" success="http://mysite.com/whatever/" /]

Auto return url takes you to the s2member page….

Thank you! ( you MUST check your email before proceeding ).

* Note: It can take ( up to 15 minutes ) for Email Confirmation with important details. If you don’t receive email confirmation in the next 15 minutes, please contact Support.
Check Your Email ( Then Click Here )

Button links to http://mysite.com/whatever/
Clicking the button takes you into the site just fine. no issues.

–test3–

w3totalcache turned on, normal database caching
no paypal-return.php
no s2-hack.php
button shortcode with success url

[s2Member-PayPal-Button level="1" ccaps="" desc="FREE for 6 months, then $2 yearly (recurring for ongoing access)." ps="mysite" lc="" cc="USD" dg="0" ns="1" custom="mysite.com" ta="0" tp="6" tt="M" ra="2.00" rp="1" rt="Y" rr="1" rrt="" rra="1" image="http://mysite.com/buywithpaypal.jpg" output="button" success="http://mysite.com/whatever/" /]

Auto return url takes you to the s2member page…

Thank you! ( you MUST check your email before proceeding ).

* Note: It can take ( up to 15 minutes ) for Email Confirmation with important details. If you don’t receive email confirmation in the next 15 minutes, please contact Support.
Check Your Email ( Then Click Here )

Button links to http://mysite.com/whatever/
Clicking the button takes you to the membership page as if you are not a paying member URL: http://mysite.com/membership/?_s2member_seeking%5Btype%5D=page&_s2member_seeking%5Bpage%5D=2&_s2member_seeking%5B_uri%5D=L3BvbG8%3D&_s2member_req%5Btype%5D=level&_s2member_req%5Blevel%5D=1&_s2member_res%5Btype%5D=page&s2member_seeking=page-2&s2member_level_req=1

each time the paypal email received an email from the site, but nothing to the site member. email…

Thank you! You’ve been updated to:
FREE for 6 months, then $2 yearly (recurring for ongoing access).

Please log back in now.
http://mysite.com/wp-login.php

Posted: Tuesday Oct 23rd, 2012 at 7:32 am #29381

Thanks for your tests.

So, if I understood correctly, deactivating W3TC everything works fine? In that case, you can try activating it with object and database caching disabled, or just use another caching plugin (e.g. QuickCache).

Then you can test adding the hack for the email customization, and then the customized return page template.

Let me know if you have any problems with that, or see any errors in the logs.

Posted: Saturday Oct 27th, 2012 at 5:29 pm #29937

I’ve noticed many threads on this site that have the same problems i’m trying to fix (not necessarily these listed below, but others) with conversation from s2member support on how to “test for bugs”, but there are never any solutions added at the end. Just “thread closed”. bummer.

;) so, I’m going to update with my successful fixes for others that might run into the same issues.

ISSUE1
resolved by moving the custom template paypal-return.php from the child theme directory to the main template directory.

ISSUE2
The caching issue was resolved by…
1 – added wp_capabilities to the non cached database queries as a fix to keep the site from caching the users level. just a note on caching *get_user_meta queries catch no matter what, use manual queries to avoid catch if in the non cached list.

2 – added s2member_paypal_return and membership to “Never cache the following pages:” on Database cache.

3 – added membership and membership/ to “Never cache the following pages:” on Page Cache.

4 – added code to the themes/childtheme/header.php to recognize if on the s2member_paypal_return url, then add ?ver=1234 (1234 being the pjp time() stamp for a completely new number) at the end of all links including the menu bar. This caused the site to recheck the users level and everything seemed fine after this.

ISSUE3
s2hacks.php MUST GO in a /wp-content/mu-plugins/ directory – even if you have to make it.
There was a typo on the wp-mail that was causing the custom email to the member to not work. $user_message should have been $users_message. Also NOTE: adding the print all $vars caused Google to flag the site email as spam, so many of the missing emails to the paypal user and the custom site notification email were later found in spam. new s2hacks.php file included below…

<?php
/*
s2member hacks for mysite.com

more info about the mu-plugins directory http://codex.wordpress.org/Must_Use_Plugins

Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php

per: http://www.primothemes.com/forums/viewtopic.php?f=4&t=10368#p33365 and http://www.s2member.com/kb/hacking-s2member/

		# Optional. s2Member® passes you an array of defined variables.
		# print_r($vars); # Would give you a list of defined variables.
		# These are PHP variables defined within the scope of the Hook,
		# at the precise point in which the Hook is fired by s2Member®.
 
		# $vars["__refs"] are also included (with some Hooks).
		# These are internal PHP variable references (very useful).
		# To learn all about references, please see PHP documentation:
		# http://www.php.net/manual/en/language.references.pass.php
*/


//Include WordPress
include('/home/content/41/9502741/html/mysite/wp-config.php');
define('WP_USE_THEMES', false);
//require('/home/content/41/9502741/html/mysite/wp-blog-header.php'); <--caused a fatal error
include('/home/content/41/9502741/html/mysite/wp-contents/plugins/mysite/mysite.php');
global $local_wp_load; //require_once('/home/content/41/9502741/html/mysite/wp-load.php');


//customize the member upgrade/downgrade email since our members are aready free members when they pay for membership.

/*
//http://www.s2member.com/codex/stable/source/s2member/includes/classes/paypal-notify-in-subscr-modify-w-level.inc.php/

//paypal_notify_in_subscr_modify_w_level.inc.php
c_ws_plugin__s2member_email_configs::email_config () . wp_mail ($paypal["payer_email"], apply_filters ("ws_plugin__s2member_modification_email_sbj", _x ("Thank you! Your account has been updated.", "s2member-front", "s2member"), get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_email_msg", _x ("Thank you! You've been updated to:", "s2member-front", "s2member") . "\n" . $paypal["item_name"] . "\n\n" . _x ("Please log back in now.", "s2member-front", "s2member") . "\n" . wp_login_url (), get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") . c_ws_plugin__s2member_email_configs::email_config_release ();


//paypal_notify_in_subscr_or_wa_w_level.inc.php
c_ws_plugin__s2member_email_configs::email_config () . wp_mail ($paypal["payer_email"], apply_filters ("ws_plugin__s2member_modification_email_sbj", _x ("Thank you! Your account has been updated.", "s2member-front", "s2member"), get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_email_msg", _x ("Thank you! You've been updated to:", "s2member-front", "s2member") . "\n" . $paypal["item_name"] . "\n\n" . _x ("Please log back in now.", "s2member-front", "s2member") . "\n" . wp_login_url (), get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") . c_ws_plugin__s2member_email_configs::email_config_release ();
*/


add_filter( "ws_plugin__s2member_modification_email_sbj", "my_s2_modification_sbj", 10, 2 );
function my_s2_modification_sbj( $s2member_default_sbj, $vars = array() ){
		if( isset($vars["user_id"]) ){ 
			$wp_userdata = get_userdata($vars["user_id"]);
			$users_name = $wp_userdata->display_name;
			//the email subject:
			return $users_name." is ready for mysite!";
		} else {
			//the email subject:
			return "Your mysite Membership is ready!";
   		}
	}//end function my_s2_modification_sbj( $s2member_default_sbj, $vars = array() )

add_filter( "ws_plugin__s2member_modification_email_msg", "my_s2_modification_msg", 10, 2 );
function my_s2_modification_msg( $s2member_default_msg, $vars = array() ){
		global $homepage_url;
        //the email message:
		//before hacks... return "Thank you! You've been updated to:\n" . $vars["paypal"]["item_name"] . "\n\nPlease log back in now:\n" . wp_login_url ();
		
		//set the members email and the site notification to send html
		$headers = 'From: mysite <info@mysite.com>' . "\r\n" . 
					//'Reply-To: ' . $from. "\r\n" . 
					'Content-Type: text/html'; //<-- adding html email ability	

		$wp_userdata = get_userdata($vars["user_id"]);
		
		$usersid = $vars["user_id"];			
		$users_email = $wp_userdata->user_email;
		$users_name = $wp_userdata->display_name;
		$sub_id = $vars["paypal"]["subscr_id"];
		$item_name = $vars["paypal"]["item_name"];
		
		//Build the user a message
		$users_subject = $users_name."! Your mysite membership is complete";
		
		$users_message = '<span style="font-family: Verdana, Geneva, sans-serif;">';
		$users_message .= 'Thanks '.$users_name.'! Your mysite membership is complete.<br>';
		$users_message .= '<br>';
		$users_message .= 'Remember to sign in the first time with the same social network, so mysite will know who you are. Associate your other networks on your profile after your first sign in.<br>';
		$users_message .= '<br>';
		$users_message .= '<h4><a href="'.$homepage_url.'/help/?id='.$usersid.'">Go fill out your profile and reply to some posts!</a></h4><br>';
		$users_message .= '<a href="'.$homepage_url.'/help/?id='.$usersid.'"><img src="http://mysite.com/wp-contents/themes/mysite/images/mysite_image.gif" border="0px"></a>';
		$users_message .= 'This link will help you get started: '.$homepage_url.'/help/?id='.$usersid.'<br>';
		$users_message .= '<br>';
		$users_message .= '<br>';
		$users_message .= '<b>mysite Member Info</b><br>';
		$users_message .= 'Name: '.$users_name.'<br>';
		$users_message .= 'mysite ID: '.$usersid.'<br>';
		$users_message .= 'email: '.$users_email.'<br>';
		$users_message .= 'Payment Subscription ID: '.$sub_id.' '.$item_name.'<br>';
		$users_message .= '<br>';
		$users_message .= 'If you have any trouble, please feel free to reply or forward this email to support@mysite.com for help.';
		$users_message .= '</span>';
	
		// SEND the mysite Member an email...
		$member_email = wp_mail($users_email, $users_subject, $users_message, $headers);	
		if( $member_email === true ){ $member_email = 'Sent Successfully'; }else{ $member_email = 'Failed'; }
		
		//build mysite a notification
		//$print_vars = print_r($vars, TRUE);
		
		$mysite_subject = 'New mysite Member: '.$users_name;

		$mysite_message = "Member Name: ".$users_name."<br>";
		$mysite_message .= "mysite ID: ".$usersid."<br>";
		$mysite_message .= "Users Email: ".$users_email."<br>";
		$mysite_message .= "<br>";
		$mysite_message .= "Payment Subscription ID: ".$sub_id."<br>";
		$mysite_message .= "Item: ".$item_name."<br>";
		$mysite_message .= "PayPal Email: ".$vars["paypal"]["payer_email"]."<br>";
		$mysite_message .= "<br>";
		//$mysite_message .= "All $vars: ".$print_vars; <-- causes gmail spam
		$mysite_message .= "Member Email: ".$member_email;
		
		// Send email to mysite - assumes $to, $subject, $message have already been defined earlier...
		wp_mail("members@mysite.com", $mysite_subject, $mysite_message, $headers);
		
			//Send the Paypal user an email...
			//before hacks... return "Thank you! You've been updated to:\n" . $vars["paypal"]["item_name"] . "\n\nPlease log back in now:\n" . wp_login_url ();
			
			/*NOTE these lines were tried and did not send an email at all as return: 
				//triggers SPAM filter "Testing all $vars: ".$print_vars;
				$paypal_users_message (with each line as $paypal_users_message .= "all quotes "and no apostrophies" as noted above"
			*/
			
			/**the following return results in a successful email to the paypay email**
			**************************************************************************
				Thanks Mira Concepts! Your mysite membership is complete.
					
				Go fill out your profile and reply to some posts!
				http://mysite.com/profile/
				
				Remember to sign in the first time with the same social network, so mysite will know who you are. Associate your other networks on your profile after your first sign in.
				
				mysite Member's Info...
				 Name: Mira Concepts
				 ID: 82
				 email: *************@gmail.com
				 Payment Subscription# ************* mysite.com $2 yearly (recurring for ongoing access).

				If you have any trouble, please feel free to reply to this email for help.
				support@mysite.com
			*/
			
			if( $users_email == $vars["payer_email"] ){
				return 	"Thanks ".$users_name."! Your mysite membership is complete.\n\nGo fill out your profile and reply to some posts! Marco?!\nThis link will help you get started: ".$homepage_url."/help/?id=".$usersid."\n\nRemember to sign in the first time with the same social network, so mysite will know who you are. Associate your other networks on your profile after your first sign in.\n\n\nmysite Member's Info...\nName: ".$users_name."\nmysite ID: ".$usersid."\nemail: ".$users_email."\n\nPayment Subscription ID: ".$sub_id." ".$item_name."\n\nIf you have any trouble, please feel free to reply or forward this email to support@mysite.com for help.";
			}
		
    }//ENd function my_s2_modification_msg( $s2member_default_msg, $vars = array() )
	
/***********************All the $vars.............................................................
	$vars: Array
                    [invoice] => 508450cc762d1~*************
                    [amount1] => 0.00
                    [amount3] => 2.00
                    [subscr_date] => 12:45:51 Oct 21, 2012 PDT
                    [payer_id] => *************
                    [mc_amount1] => 0.00
                    [mc_amount3] => 2.00
                    [charset] => windows-1252
                    [first_name] => *************
                    [option_selection1] => 74
                    [option_selection2] => *************
                    [reattempt] => 1
                    [notify_version] => 3.7
                    [subscr_id] => *************
                    [custom] => mysite.com
                    [payer_status] => verified
                    [business] => info@myste.net
                    [verify_sign] => *************
                    [payer_email] => order@mysite.com
                    [option_name1] => Referencing Customer ID
                    [option_name2] => Customer IP Address
                    [payer_business_name] => *************
                    [last_name] => *************
                    [receiver_email] => info@mysite.net
                    [recurring] => 1
                    [txn_type] => subscr_signup
                    [item_name] => mysite.com FREE for 6 months, then $2 yearly (recurring for ongoing access).
                    [mc_currency] => USD
                    [item_number] => 1
                    [residence_country] => US
                    [period1] => 6 M
                    [period3] => 1 Y
                    [ipn_track_id] => *************
                    [s2member_log] => Array
                        (
                            [0] => IPN received on: Sun Oct 21, 2012 7:46:13 pm UTC
                            [1] => s2Member POST vars verified through a POST back to PayPal®.
                            [2] => s2Member originating domain ( `$_SERVER["HTTP_HOST"]` ) validated.
                        )

                    [subscr_gateway] => paypal
                )

            [_paypal] => Array
                (
                    [invoice] => *************
                    [amount1] => 0.00
                    [amount3] => 2.00
                    [subscr_date] => 12:45:51 Oct 21, 2012 PDT
                    [payer_id] => *************
                    [mc_amount1] => 0.00
                    [mc_amount3] => 2.00
                    [charset] => windows-1252
                    [first_name] => *************
                    [option_selection1] => 74
                    [option_selection2] => *************
                    [reattempt] => 1
                    [notify_version] => 3.7
                    [subscr_id] => *************
                    [custom] => mysite.com
                    [payer_status] => verified
                    [business] => info@*************.net
                    [verify_sign] => *************
                    [payer_email] => order@*************.com
                    [option_name1] => Referencing Customer ID
                    [option_name2] => Customer IP Address
                    [payer_business_name] => *************
                    [last_name] => *************
                    [receiver_email] => info@*************.net
                    [recurring] => 1
                    [txn_type] => subscr_signup
                    [item_name] => mysite.com FREE for 6 months, then $2 yearly (recurring for ongoing access).
                    [mc_currency] => USD
                    [item_number] => 1
                    [residence_country] => US
                    [period1] => 6 M
                    [period3] => 1 Y
                    [ipn_track_id] => *************
                )

            [_paypal_s] => a:33:{s:7:"invoice";s:27:"*************1~*************";s:7:"amount1";s:4:"0.00";s:7:"amount3";s:4:"2.00";s:11:"subscr_date";s:25:"12:45:51 Oct 21, 2012 PDT";s:8:"payer_id";s:13:"*************";s:10:"mc_amount1";s:4:"0.00";s:10:"mc_amount3";s:4:"2.00";s:7:"charset";s:12:"windows-1252";s:10:"first_name";s:5:"*********";s:17:"option_selection1";s:2:"74";s:17:"option_selection2";s:13:"*************";s:9:"reattempt";s:1:"1";s:14:"notify_version";s:3:"3.7";s:9:"subscr_id";s:14:"*************";s:6:"custom";s:13:"mysite.com";s:12:"payer_status";s:8:"verified";s:8:"business";s:21:"info@*********.net";s:11:"verify_sign";s:56:"*************-*************.*************";s:11:"payer_email";s:24:"order@*************.com";s:12:"option_name1";s:23:"Referencing Customer ID";s:12:"option_name2";s:19:"Customer IP Address";s:19:"payer_business_name";s:36:"************* Art and Design Studio";s:9:"last_name";s:9:"*************";s:14:"receiver_email";s:21:"info@*********.net";s:9:"recurring";s:1:"1";s:8:"txn_type";s:13:"subscr_signup";s:9:"item_name";s:79:"mysite.com FREE for 6 months, then $2 yearly (recurring for ongoing access).";s:11:"mc_currency";s:3:"USD";s:11:"item_number";s:1:"1";s:17:"residence_country";s:2:"US";s:7:"period1";s:3:"6 M";s:7:"period3";s:3:"1 Y";s:12:"ipn_track_id";s:13:"*************";}
            [invoice] => 508450cc762d1~*************
            [amount1] => 0.00
            [amount3] => 2.00
            [subscr_date] => 12:45:51 Oct 21, 2012 PDT
            [payer_id] => *************
            [mc_amount1] => 0.00
            [mc_amount3] => 2.00
            [charset] => windows-1252
            [first_name] => *********
            [option_selection1] => 74
            [option_selection2] => *************
            [reattempt] => 1
            [notify_version] => 3.7
            [subscr_id] => *************
            [custom] => mysite.com
            [payer_status] => verified
            [business] => info@*********.net
            [verify_sign] => *************
            [payer_email] => order@*************.com
            [option_name1] => Referencing Customer ID
            [option_name2] => Customer IP Address
            [payer_business_name] => ************* Art and Design Studio
            [last_name] => *********
            [receiver_email] => info@*********.net
            [recurring] => 2.00
            [txn_type] => subscr_signup
            [item_name] => mysite.com FREE for 6 months, then $2 yearly (recurring for ongoing access).
            [mc_currency] => USD
            [item_number] => 1
            [residence_country] => US
            [period1] => 6 M
            [period3] => 1 Y
            [ipn_track_id] => *************
            [s2member_log] => Array
                (
                    [0] => IPN received on: Sun Oct 21, 2012 7:46:13 pm UTC
                    [1] => s2Member POST vars verified through a POST back to PayPal®.
                    [2] => s2Member originating domain ( `$_SERVER["HTTP_HOST"]` ) validated.
                    [3] => s2Member `txn_type` identified as ( `web_accept|subscr_signup` ).
                    [4] => s2Member `txn_type` identified as ( `web_accept|subscr_signup` ) w/ update vars.
                    [5] => s2Member Level/Capabilities updated w/ advanced update routines.
                )

            [subscr_gateway] => paypal
            [eotper] =>
            [ccaps] =>
            [level] => 1
            [ip] => *************
            [initial_term] => 6 M
            [initial] => 0.00
            [regular] => 2.00
            [regular_term] => 1 Y
        )

*/	
?>

yea, now on to more issues with google checkout. OH BOY lol. This plugin is very helpful and we purchased the multi-site license. I would not however recommend it for those who don’t have time to put into debugging and writing custom code for customizing it to work with their site. The basic setup alone takes a person willing to do a lot of reading.

It would be a great feature to add a member level upgrade custom email, so the s2hacks file wouldn’t needed. Also, sending that email to both the paypal user and the site member if their emails differ.

cheers, and again thanks for the tips :)

Posted: Monday Oct 29th, 2012 at 2:00 am #29995

Thanks a lot for taking the time to post an update with your solutions. :)

s2hacks.php MUST GO in a /wp-content/mu-plugins/ directory – even if you have to make it.

That’s right. I thought you had put it there, since that’s what we indicate when we recommend using an s2hacks.php file. I now re-read your first post and saw you did say “/wp-content/plugins/s2-Hacks.php” there, which is wrong and I missed the first time.

I would not however recommend it for those who don’t have time to put into debugging and writing custom code for customizing it to work with their site.

Customization of a plugin’s behavior with hacks will always be more advanced than using an interface, regardless of the plugin. s2Member makes it possible to do these customizations, while some others obscure the code, though. That said, we do want to make more things possible through the user interface.

It would be a great feature to add a member level upgrade custom email, so the s2hacks file wouldn’t needed. Also, sending that email to both the paypal user and the site member if their emails differ.

I took note of that. This is something we’re planning to add.

This plugin is very helpful and we purchased the multi-site license.

Thank you! :)

Viewing 5 replies - 1 through 5 (of 5 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.