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.

s2Member-PayPal-Button short code in welcome

Home Forums Community Forum s2Member-PayPal-Button short code in welcome

This topic contains 6 replies, has 4 voices. Last updated by  Jason (Lead Developer) 4 years, 7 months ago.

Topic Author Topic
Posted: Sunday Jun 3rd, 2012 at 8:38 am #15278

I put the welcome email as html as shown here. http://www.s2member.com/forums/topic/html-in-welcome-emails/ I am now trying to include the paypal button shortcode in that welcome email for the customer.

I have added s2member\includes\classes\email-configs.inc.php line 240

$msg .= do_shortcode( '[s2Member-PayPal-Button level="2" ccaps="" desc="Annual Membership" ps="paypal" lc="" cc="AUD" dg="0" ns="1" custom="localhost" ta="195" tp="1" tt="Y" ra="195" rp="1" rt="Y" rr="1" rrt="" rra="1" image="default" output="url" /]' );

and when i get the welcome email it has the paypal url added however when you click on it, it is missing the subscriber id etc. So i’m sure its not generating all the information.

Can you suggest how i go about including a paypal payment link in the welcome email that will link the payment to the customers account?

List Of Topic Replies

Viewing 6 replies - 1 through 6 (of 6 total)
Author Replies
Author Replies
Posted: Monday Jun 4th, 2012 at 7:37 am #15347

I emailed Jason asking him how you could reference the new user account so the payment upgrades it.

Posted: Monday Jun 4th, 2012 at 7:40 am #15349
Raam Dev
Username: Raam
Staff Member

Hello,

If you’re using the above shortcode on a live installation, it won’t work becuase the custom= attribute must contain the domain of the site where your s2Member is installed (it’s currently set to localhost).

Also, have you tried generating the PayPal URL by putting the shortcode on a WordPress page, viewing the page, and then copy/pasting the resulting URL into the email?

Posted: Monday Jun 4th, 2012 at 10:23 am #15371

Hi,

Thank you both for my replies. Ill await your answer from Jason as that seems to be what you said in your response.

I tried adding the domain to the custom field and uploading to a live site however still the same result. I compared the url from the welcome email (after going through the shortcode straight after account created) and then the url from when that user is logged in and the shortcode run.

Everything was the same except for the following differences:

Logged in User

s2member_paypal_return_tra=has a different lot of characters
&on0=Referencing+Customer+ID
&os0=28

when i go through check out it will allocate the paypal payment to the account because the customer id was specified.

Welcome Email run shortcode

is the same as the above except these three fields are different

s2member_paypal_return_tra=has a different lot of characters
&on0=Originating+Domain
&os0=mydomainhere.com.au

when i go through the paypal checkout it obviously doesn’t have the customer ID so cannot automatically upgrade their account. I was prompted that payment was successful and to create another and i already had a user account hence the welcome email from a step before. I prefer account creation first rather than payment. I have a payment reminder on the home page once they log in but it would still be nice if its possible to get the email payment link to work.

Thanks for any further help if you can think of a quick hack or cut and paste of an existing method and a line or two needing to be changed.

Posted: Thursday Jun 7th, 2012 at 5:32 pm #15845
Staff Member

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&#91;'paypal'&#93;)) // 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('&#91;&#91;s2Member-PayPal-Button ... output="url" /&#93;&#93;');
					// 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
Posted: Thursday Jun 7th, 2012 at 7:49 pm #15859

Thanks Jason! Great idea.

Dataca, if you notice the s2Member shortcode not outputting the URL correctly, try using [hilite mono]wp_loaded[/hilite] instead of the [hilite mono]init[/hilite] hook.

Also, that link in the email will always be sending the user to pay, so if he uses it again in the future, he may be asked to pay again incorrectly. Another thing you could do is just provide a regular login link, without any redirection, and in your hack instead check the user’s role. If he doesn’t have the paid role, redirect him to pay over at PayPal.

Posted: Thursday Jun 7th, 2012 at 7:55 pm #15862
Staff Member
Very welcome. I agree, the “wp_loaded” hook is better here.
~ Code sample updated to use “wp_loaded” hook instead.
Viewing 6 replies - 1 through 6 (of 6 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.