Thanks for the heads up on this request for support.
Since the user is NOT logged in during the generation of the PayPal Button, it makes this very difficult to accomplish with any reliability, because the Button is generated with detection of the current User’s ID, and also with the IP address of the current user. So really, we need them to be logged into the site.
There is another way, which might help you accomplish this however.
My suggestion is to place a simple link in the email, which leads a customer to a dynamic redirection on the site.
In other words, instead of generating the button, and putting it into the email; generate a link which leads to a script that generates the button and redirects the user (all in one shot).
I posted an example of this for ClickBank, which should work just fine with a PayPal Button as well:
See: http://www.s2member.com/forums/topic/using-clickbank-and-paypal/#post-11438
You will NEED the user to be logged-in first though. So whatever you come up with, be sure to force the user to be logged in prior to generating the Shortcode. This can be accomplished by routing your customer through a login link, which includes a redirect_to value.
I’ll go ahead and write this up here as a quick example:
Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
<?php
add_action('wp_loaded', 'handle_dynamic_paypal_redirections');
function handle_dynamic_paypal_redirections()
{
if(!empty($_GET['paypal'])) // A url leading to this site, with: /?paypal=redirect
{
if(is_user_logged_in()) // Only generate Shortcode if customer is logged in.
{
$paypal_checkout = do_shortcode('[[s2Member-PayPal-Button ... output="url" /]]');
// The Shortcode has been abbreviated here for clarity in this regard.
// You will need to generate your own full Shortcode, and set output="url".
// Redirect the potential customer now to PayPal.
wp_redirect($paypal_checkout); exit;
}
}
}
?>
With this MU plugin in place. Now create this link.
Here we force the customer to be logged in, before hitting our dynamic redirection handler.
http://yoursite.com/wp-login.php?redirect_to=http://yoursite.com/?paypal=redirect
The redirect_to value, really should be URL-encoded, so the link should actually come out like this:
http://yoursite.com/wp-login.php?redirect_to=http%3A%2F%2Fyoursite.com%2F%3Fpaypal%3Dredirect
You could shorten this link up a bit further, using something like tinyURL.
Click here to log in and upgrade your account: http://tinyurl.com/7nh7wyn
In Summary…
The customer gets an email with this link:
http://yoursite.com/wp-login.php?redirect_to=http://yoursite.com/?paypal=redirect
(or perhaps just: http://tinyurl.com/7nh7wyn, if you prefer that)
They are asked to log in.
After logging in, they are immediately redirected to:
http://yoursite.com/?paypal=redirect Which immediately redirects them again, over to PayPal, with the proper link, which considers their existing user status on your site. The existing account is upgraded, and the customer does NOT need to re-register after checkout.
-
This reply was modified 4 years, 7 months ago by
Jason (Lead Developer). Reason: Updated code sample to wp_loaded hook instead of init