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