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™

Redirect based on URL variable...

s2Member Plugin. A Membership plugin for WordPress®.

Redirect based on URL variable...

Postby rwilki » October 26th, 2011, 10:55 am

This is a new question based on an old thread. With the help of another forum user (joeboydston) I was able to make s2Member function more intuitively.

Basically, when a reader clicks on a level #0 or #1 post, they either have to be logged in to the correct level or register/pay. Once a reader logged in, they were redirected to the protected post rather than the Membership Options page.

The hack uses the sidebar-login plugin and the shortcode-exec-php plugin to make it function. There have been a lot of updates to s2Member since I last posted in this forum but I'd like some help with a tweak. I would like to know if I can use the redirect functionality without having to use the login sidebar. In other words, is there a way to pass on the variable in the protected url through the wp login page? Here is my code. Any help would be great. I just find it so annoying that the Membership Options page is mandatory.

Code: Select all
<script type="text/javascript">// <![CDATA[
/* <![CDATA[ */
    jQuery.noConflict();
    jQuery(document).ready(function($){
       $(".redirect_to").val("[s2_redirect]");
    });
/*  */
// ]]></script>
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: Redirect based on URL variable...

Postby Cristián Lávaque » October 26th, 2011, 11:22 pm

Sorry, I don't know JavaScript, so I'm not sure how that hack works.

I can tell you that if you add the redirect_to variable to the URL for the login page, that's where the person will be take after login.

http://example.com/login.php?redirect_t ... rson-to-go
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: Redirect based on URL variable...

Postby rwilki » October 27th, 2011, 8:38 am

Thanks Cristian. That's an interesting approach. I'm wondering how I can do this in a more dynamic method.

My url for a protected article might be:

http://www.mydomain.com/news-article-may-15-2011 basically, I want the redirect to go to this article once people have registered or logged in. Essentially bypassing the MO page. I don't see how I could hardcode this in every link on my site since the url is created by my publishing of the post and I would have to manually do this for every article...
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: Redirect based on URL variable...

Postby Cristián Lávaque » October 27th, 2011, 11:16 pm

Could you show me where your login link/form is? You can send it via the contact form if you don't want to make it public. http://s2member.com/contact

I'm guessing you want to have this return to the page either when the person clicks the login link on it, or if he gets taken to the Membership Options and you remind him to login to view the page, right?

You can use variables in both cases to create the redirect_to value. When in the MOP, you have the MOP vars which will include the post/page that bounced the user. WP Admin -> s2Member -> API / Scripting -> Membership Options Page Variables

So you can do something like:

Code: Select all
<?php $p = explode('-', $_GET['s2member_seeking']); ?>
<a href="<?php echo wp_login_url('/?p=' . $p[1]); ?>" title="Login">Login</a>


http://codex.wordpress.org/Function_Ref ... _login_url

I hope this 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: Redirect based on URL variable...

Postby rwilki » October 31st, 2011, 9:18 am

Thanks for this idea Cristian! I'm sorry for my delayed reply. I'll try this out and send you the login link if I can't get it to work. Your support is incredible!

Thanks,
Bob
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: Redirect based on URL variable...

Postby Cristián Lávaque » October 31st, 2011, 11:30 pm

You're welcome! Thanks for the kudos. :)
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 1 guest

cron