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.

Redirect back to previous page after login

Home Forums Community Forum Redirect back to previous page after login

Tagged: 

This topic contains 2 replies, has 2 voices. Last updated by  David Wang 4 years, 8 months ago.

Topic Author Topic
Posted: Tuesday Apr 17th, 2012 at 12:12 pm #11010

This is what I want to do:

1. Visitor lands on protected page example.com/protected
2. Visitor gets sent to Membership Options Page. I have a login form here.
3. After logging in, the visitor gets sent back to example.com/protected

Is there a way to do this? Thanks

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Tuesday Apr 17th, 2012 at 12:37 pm #11013
Bruce
Username: Bruce
Staff Member

Hi David, thanks for your inquiry!

s2Member sends data about the page the user was redirected from to the Membership Options Page when they are redirected. You can use the $_GET[‘_s2member_seeking’] array in the URL to create a form that will do this.

Here’s an example of a simple form that works this way (remember that to do this you need a PHP Execution plugin installed to use PHP in a WordPress page/post)

<?php
$s2member_seeking = $_GET&#91;'_s2member_seeking'&#93;;

if($s2member_seeking)
    {
        if($s2member_seeking&#91;'type'&#93; === 'post')
            $action = site_url().'/wp-login.php?redirect_to=/p='.$s2member_seeking&#91;'post'&#93;;
        else if($s2member_seeking&#91;'type'&#93; === 'page')
            $action = site_url().'/wp-login.php?redirect_to=/page='.$s2member_seeking&#91;'page'&#93;;
    }
?>
<form method="post" action="<?php echo $action; ?>">
    <input type="text" name="log" />
    <input type="text" name="pwd" />

    <input type="submit" value="Sign In" />
</form>

Remember that the [‘type’] value affects how this work, and you made need to change things to get this to work correctly with your WordPress® Setup!

I hope this helps!

Posted: Tuesday Apr 17th, 2012 at 9:02 pm #11051

Oh that’s great! I can figure it out from this. Thanks.

(But please look at the update on my other thread → http://www.s2member.com/forums/topic/nothing-happens-when-paypal-button-is-clicked/)

Viewing 2 replies - 1 through 2 (of 2 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.