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™

Setting login welcome page to referring page/previous page

s2Member Plugin. A Membership plugin for WordPress®.

Setting login welcome page to referring page/previous page

Postby lanyard13 » March 28th, 2011, 8:08 pm

Hi, I am using s2Member Pro. Referencing this post http://bit.ly/emIaA9 and this post http://bit.ly/gUlA0N, I would like a little more help or information on this particular topic, of redirecting users back to the page they were on before logging in.

This Code was provided on the second post and I was wondering where it would go?
Code: Select all
    <?php
    
if (is_user_logged_in () && current_user_can ("access_s2member_level4"))
        {
            echo 
'<p class="login-links">';
            echo 
'<span class="login-greeting">Welcome back, ' S2MEMBER_CURRENT_USER_FIRST_NAME '</span><br />';
            echo 
'<a href="http://www.workplacecoachinstitute.com/cmd.php?cmd=cart">View Cart</a> <span class="login-spacing">|</span> ';
            echo 
'<a href="http://workplacecoachinstitute.com/?s2member_profile=1">Profile</a> <span class="login-spacing">|</span> ';
            echo 
'<a href="http://workplacecoachinstitute.com/wp-login.php?action=logout">Logout</a>';
            echo 
'</p>';
        }
    else
        {
            echo 
'<p>';
            echo 
'<a href="http://www.workplacecoachinstitute.com/cmd.php?cmd=cart">View Cart</a> <span class="login-spacing">|</span> ';
            echo 
'<a href="http://workplacecoachinstitute.com/wp-login.php?redirect_to=' rawurlencode ($_SERVER["REQUEST_URI"]) . '">Login</a>';
            echo 
'</p>';
        }
    
?>

From the Second Post as well:
If they were on the About page and logged in, I would want them to return to the About page.
If they were on the Services page and logged in, I would want them to return to the Services page.


I don't have a lot of PHP experience but am comfortable enough with Wordpress at this point to understand how the files work together (for the most part). This is something my client would like and I've searched the forum for quite a bit, these are the closest to getting what I want that I've found but don't quite understand how to do it.

Thanks in advance for your help!
User avatar
lanyard13
Registered User
Registered User
 
Posts: 3
Joined: March 28, 2011

Re: Setting login welcome page to referring page/previous pa

Postby Cristián Lávaque » March 28th, 2011, 8:24 pm

You'd use that code where you want the login link to be. If you already have a login link in your theme, you'd need to edit the theme file that has the code for it and replace it with this one to achieve what you want.

Since you have s2Member Pro, you could also try the Pro Login Widget that comes with it, and set it to take the person to the previous page after login. WP Admin -> Appearance -> Widgets -> s2Member Pro Login Widget -> Redirection After Login.

If you want to use that widget in other places, read this documentation WP Admin -> s2Member -> API Scripting -> Pro Login Widget.

Let me know if 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: Setting login welcome page to referring page/previous pa

Postby lanyard13 » March 29th, 2011, 10:02 am

Hi,
thanks for the quick response!

Ok, the login widget looks like a good solution; going to try that out. Can you do the same thing after a user registers, direct them back to the page they were on rather than the login screen (client request)?
User avatar
lanyard13
Registered User
Registered User
 
Posts: 3
Joined: March 28, 2011

Re: Setting login welcome page to referring page/previous pa

Postby Cristián Lávaque » March 29th, 2011, 6:32 pm

What payment gateway will you be using?

In s2Member Pro, Pro-Forms for PayPal or Authorize.Net allow you to specify a return URL on success. You can read about it in here WP Admin -> s2Member -> PayPal/Auth.Net Pro-Forms -> Custom Return URLs On Success.
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: Setting login welcome page to referring page/previous pa

Postby lanyard13 » March 29th, 2011, 8:01 pm

Hi Cristian,
Ok, so I'm digging into the 'suggested reading' :D (which thank you very much for directing me!!).

I'm starting to get a feel for this... I think. :? If you're using Paypal, when you generate the form for pro forms, this custom redirection is an option but if you're just using a Free Membership/Subscription, then you can't do a custom redirection?
User avatar
lanyard13
Registered User
Registered User
 
Posts: 3
Joined: March 28, 2011

Re: Setting login welcome page to referring page/previous pa

Postby Cristián Lávaque » March 29th, 2011, 9:33 pm

You're welcome. :)

You could try the free registration with teh "success" attribute and if that doesn't work, try "redirect_to".

If the shortform doesn't accept that attribute, then try the full code and add it as a hidden field and see if that does the trick.
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: Google [Bot], Yahoo [Bot] and 2 guests

cron