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™

automatic redirect to members page after open registration

s2Member Plugin. A Membership plugin for WordPress®.

automatic redirect to members page after open registration

Postby glbrent » July 23rd, 2011, 8:27 pm

I have s2member pro. I'm trying to make my open registration form redirect the user to my member page as soon as they register on my site. However, It doesn't seem to do. So right now I have it setup to a thank you page:
Code: Select all
success="https://apazones.com/thankyou"
. The "thank you page" just says thank you and check your email for username/password:

However, what I NEED and was thinking that I could simply pass the login/password variables into the success page redirect so it could still go to the members page like this
Code: Select all
success="https://apazones.com/members/?user_login=%%user_login%%&user_pass=%%user_pass%%"

but that doesn't seem to work either.

I also have Login with ajax running as well. My members page is set to level 0 so it shouldn't be a premission issues if I could pass the newly created variables and automatically login.
I've also tried to let the password be userdefined.
Am I having a plugin conflict or just a coding or redirect conflict?
Thank You
User avatar
glbrent
Registered User
Registered User
 
Posts: 21
Joined: July 19, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » July 25th, 2011, 8:36 pm

The default after registration is to have the user login. I wrote a hack to have him logged in automatically after registration and redirected to the page you specify. Here it is:

/wp-content/mu-plugins/s2hacks.php
Code: Select all
<?php
add_action
('ws_plugin__s2member_during_configure_user_registration_front_side', 's2_auto_login_after_registration');
function s2_auto_login_after_registration($vars = array()) {
    wp_set_auth_cookie($vars['user_id'], false, is_ssl());
    wp_redirect(S2MEMBER_LOGIN_WELCOME_PAGE_URL . '?first');
    exit;
}
?>


I hope it 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: automatic redirect to members page after open registrati

Postby Cristián Lávaque » July 25th, 2011, 10:44 pm

By the way, you can use the first variable in the Login Welcome Page's URL, in a conditional to display a different message for new members.

Code: Select all
<?php if (isset($_GET['first']) { ?>
Welcome new user.
<?php } else { ?>
Welcome returning user.
<?php } ?>


You need a PHP execution plugin for that code to work in a WordPress page. https://wordpress.org/extend/plugins/exec-php/
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: automatic redirect to members page after open registrati

Postby glbrent » July 26th, 2011, 12:57 am

wow, thanks Cristian! that's an awesome little hack!!
User avatar
glbrent
Registered User
Registered User
 
Posts: 21
Joined: July 19, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » July 26th, 2011, 2:42 am

;)
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: automatic redirect to members page after open registrati

Postby rwilki » July 26th, 2011, 8:36 am

i'm getting errors with this code. tried it in template and also in page with exec-php plugin. i'm getting syntax errors. do i also need the hack above?

<?php
add_action('ws_plugin__s2member_during_configure_user_registration_front_side', 's2_auto_login_after_registration');
function s2_auto_login_after_registration($vars = array()) {
wp_set_auth_cookie($vars['user_id'], false, is_ssl());
wp_redirect(S2MEMBER_LOGIN_WELCOME_PAGE_URL . '?first');
exit;
}
?>

I'm not sure where to put this...
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » July 26th, 2011, 11:51 pm

The hack would go in this directory/file (create them if you don't have them) /wp-content/mu-plugins/s2hacks.php

What error are you getting?
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: automatic redirect to members page after open registrati

Postby btuk1 » August 3rd, 2011, 6:33 pm

Thank you Cristián !

That was really annoying me and your hack works superbly!

I love s2Member, it really is a fantastic script!!!
User avatar
btuk1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: automatic redirect to members page after open registrati

Postby btuk1 » August 3rd, 2011, 8:13 pm

One problem with the hack is that if you are using the "On Registration" API Notification, the hack seems to overide it and doesn't trigger any custom routines.

A quick look at the code and I think I can just use:

Code: Select all
wp_set_auth_cookie($vars['user_id'], false, is_ssl());
wp_redirect(S2MEMBER_LOGIN_WELCOME_PAGE_URL . '?first');


At the end of my scripts as I pass the UserID any how.

I am not a coder and cookies is out of my realm but I muddle through.
User avatar
btuk1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 4th, 2011, 12:10 am

Thanks for the kudos! :)

Are you trying to use the Registration or Signup Notification?
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: automatic redirect to members page after open registrati

Postby btuk1 » August 4th, 2011, 3:54 am

I am using the Registration Notification
User avatar
btuk1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 5th, 2011, 12:17 am

OK. Could you try this for the hack?

Create this dir/file /wp-content/mu-plugins/s2hacks.php
Code: Select all
<?php
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(S2MEMBER_LOGIN_WELCOME_PAGE_URL . '?first');
        exit();
    }
}
?>
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: automatic redirect to members page after open registrati

Postby btuk1 » August 5th, 2011, 4:39 am

Well done Cristián !

That works exactly as needed.

This is why s2Member amazes me.
It is just such a powerful framework that is incredibly flexible and just look how small and neat the bespoke customization can be.

How on earth this quality is free or such a small price for the Pro version is almost beyond me.

Many thanks Cristián, your knowledge is fantastic.
User avatar
btuk1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 5th, 2011, 10:24 pm

Thanks for the kudos! And thanks for confiriming it worked. :)

It was Jason who helped me fixing the notification problem. I didn't know what was wrong. :P
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: automatic redirect to members page after open registrati

Postby btuk1 » August 5th, 2011, 11:52 pm

Well it's an awesome team.

Thanks to you both!
User avatar
btuk1
Registered User
Registered User
 
Posts: 7
Joined: July 1, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 6th, 2011, 12:29 am

:)
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: automatic redirect to members page after open registrati

Postby rwilki » August 12th, 2011, 2:16 pm

Cristian, thanks to you, I've got this working great. It automatically logs someone in after registration. And thanks to help from Joe, I've managed to have a redirection to protected content after login from Member Options page. Is there a way to do the same thing after registration? In other words, to have the visitor redirected to the protected content upon registration?

Thanks,
Bob

Cristián Lávaque wrote:The default after registration is to have the user login. I wrote a hack to have him logged in automatically after registration and redirected to the page you specify. Here it is:

/wp-content/mu-plugins/s2hacks.php
Code: Select all
<?php
add_action
('ws_plugin__s2member_during_configure_user_registration_front_side', 's2_auto_login_after_registration');
function s2_auto_login_after_registration($vars = array()) {
    wp_set_auth_cookie($vars['user_id'], false, is_ssl());
    wp_redirect(S2MEMBER_LOGIN_WELCOME_PAGE_URL . '?first');
    exit;
}
?>


I hope it helps. :)
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 12th, 2011, 3:41 pm

Thanks for the kudos, you're very welcome. :)

You can just change the URL in the wp_redirect line so instead of the Login Welcome he goes to the other protected page.
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: automatic redirect to members page after open registrati

Postby rwilki » August 12th, 2011, 4:23 pm

Cristian, this is a dynamic variable depending upon what post someone clicked on. So how would I know what the url would be? My other redirect from the login uses a javascript shortcode to

===
$post = preg_split('/-/', $_GET['s2member_seeking']);
echo "/?p=" . $post[1];
===

and then on the member options page, I have this code

===
<script type="text/javascript">// <![CDATA[
/* <![CDATA[ */
jQuery.noConflict();
jQuery(document).ready(function($){
$(".redirect_to").val("[s2_redirect]");
});
/* */
// ]]></script>
===

So a visitor upon clicking a link > logging in > is redirected to protected post. I just want the same for the registration process, after logging in, is this possible?
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 12th, 2011, 5:30 pm

Yeah, I understand. I don't know how to do that with JS, you should ask Joe who gave you the login redirect tip.

What I suggested for the registration was to save in a cookie/session the MOP var or the URL to the page that bounced him, so you have it available when you want to redirect with my hack. E.g. wp_redirect($_COOKIE['URL_to_page_that_bounced_him']);
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: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 15th, 2011, 2:20 pm

Here's an update to the hack, to fix a problem with new user emails not being sent to the user or admin.

Create this dir/file: /wp-content/mu-plugins/s2hacks.php
Code: Select all
<?php
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_new_user_notification($vars['user_id'], $vars['pass']);
        wp_set_auth_cookie($vars['user_id'], false, is_ssl());
        wp_redirect(S2MEMBER_LOGIN_WELCOME_PAGE_URL . '?first');
        exit();
    }
}
?>


Thank you Jason for your help with this again.
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: automatic redirect to members page after open registrati

Postby glbrent » August 15th, 2011, 4:23 pm

SUBLIME! Thank you Cristian!
User avatar
glbrent
Registered User
Registered User
 
Posts: 21
Joined: July 19, 2011

Re: automatic redirect to members page after open registrati

Postby rwilki » August 16th, 2011, 11:39 am

Cristián Lávaque wrote:Yeah, I understand. I don't know how to do that with JS, you should ask Joe who gave you the login redirect tip.

What I suggested for the registration was to save in a cookie/session the MOP var or the URL to the page that bounced him, so you have it available when you want to redirect with my hack. E.g. wp_redirect($_COOKIE['URL_to_page_that_bounced_him']);


Thanks for replying. I'll keep trying to configure this. I appreciate your followups. Your support is A+!
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 17th, 2011, 3:01 am

Thanks for the kudos guys. I'm glad to help. :)
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: automatic redirect to members page after open registrati

Postby rwilki » August 17th, 2011, 3:10 am

Cristian, has anyone posted any examples of MOP variables for us to learn from? Almost all of the code is for logged in visitors. I can't get it to work for users seeking certain level content who are not logged in.

Am using
Code: Select all
<?php } elseif { ($_GET['s2member_level_required'] === '0') ?>
By registering now...
<?php } elseif { ($_GET['s2member_level_required'] === '1') ?>
Premium Access Pass...
<?php } ?>


But it's not filtering anything. It's showing both areas of content regardless of which level content is required. I'm testing this as an unlogged in visitor...
Last edited by Cristián Lávaque on August 17th, 2011, 3:14 am, edited 1 time in total.
Reason: Improve code readability. http://www.primothemes.com/forums/viewtopic.php?f=36&t=2780
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Next

Return to s2Member Plugin

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 2 guests

cron