PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Auto Login On PayPal Return?

s2Member Plugin. A Membership plugin for WordPress®.

Auto Login On PayPal Return?

Postby ryanseo » November 3rd, 2011, 8:44 pm

Is there a way to edit your return template to automatically log the user in with the username/password details they entered into the PayPal Pro Form registration form so I can use that to log the person in automatically , thus taking them to the set Login Page (in my case, it's the author template which utilizes a number of custom functionality to show the user's posts on the front end, etc)
User avatar
ryanseo
Registered User
Registered User
 
Posts: 27
Joined: January 10, 2011

Re: Auto Login On PayPal Return?

Postby ryanseo » November 3rd, 2011, 9:36 pm

This has been figured out:

Adding this into your theme's function files will set a cookie for you and automatically log you in after registering and returning back from a successful PayPal membership purchase (since the registration uses built in WP registration functionality):

Code: Select all
function auto_login_new_user( $user_id )
    {
      wp_set_auth_cookie( $user_id, false, is_ssl() );
    }
add_action( 'user_register', 'auto_login_new_user' );


Hope this helps someone who also needs this kind of functionality.

**Note: Not sure if this works with s2member non-pro forms as I'm utilizing the Pro Forms but if it uses the same wp registration functionality then it should absolutely work for non-pro members as well.
User avatar
ryanseo
Registered User
Registered User
 
Posts: 27
Joined: January 10, 2011

Re: Auto Login On PayPal Return?

Postby Eduan » November 3rd, 2011, 11:08 pm

Okay, glad you solved it!
Now officially accepting Professional s2Member installations along with Bruce C (a.k.a. Ace).

If you're interested in a Professional s2Member Installation, or a Custom Coding Job, you can send your request here.
User avatar
Eduan
Experienced User
Experienced User
 
Posts: 1154
Joined: August 27, 2011
Location: Taxco de Alarcón, Guerrero, México.

Re: Auto Login On PayPal Return?

Postby Cristián Lávaque » November 4th, 2011, 12:30 am

Ryan, that may miss some functionality like the Notifications API, the new user and confirmation emails. Please see this thread: viewtopic.php?f=4&t=14211

I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Auto Login On PayPal Return?

Postby ryanseo » November 4th, 2011, 9:04 am

Cristian,

Thank you very much sir.

Code: Select all
add_action ('ws_plugin__s2member_during_configure_user_registration', 's2_auto_login_after_registration');
function s2_auto_login_after_registration($vars = array()) {
    if (!is_admin() && $vars['processed'] === 'yes') {
        wp_set_auth_cookie($vars['user_id'], false, is_ssl());
        wp_redirect('urltoredirectto');
        exit();
    }
}


Worked perfectly and I receive notifications like I should be, good eye and thanks again.
User avatar
ryanseo
Registered User
Registered User
 
Posts: 27
Joined: January 10, 2011

Re: Auto Login On PayPal Return?

Postby Cristián Lávaque » November 4th, 2011, 2:00 pm

My pleasure. :)

Make sure the user gets the emails too (new user and payment confirmation).
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Auto Login On PayPal Return?

Postby ryanseo » November 4th, 2011, 2:09 pm

Yep, they work perfectly as well, thanks for the help on that.
User avatar
ryanseo
Registered User
Registered User
 
Posts: 27
Joined: January 10, 2011

Re: Auto Login On PayPal Return?

Postby Cristián Lávaque » November 5th, 2011, 10:33 pm

Excellent. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

cron