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®.

Re: automatic redirect to members page after open registrati

Postby RJGonzalez » August 17th, 2011, 3:14 am

I see recent activity here so i will try to get an answer from here, hopes it dont bother no one.

I have search and there are many solutions but cant figure it out. It has to do with the login redirect. Here is my code:

Code: Select all
<p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.', 'kubrick'), get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode(get_permalink())); ?></p>


Now where is it that i have redirect to?

Thank you in advance.
Always willing to help, securely at http://www.149host.com
User avatar
RJGonzalez
Registered User
Registered User
 
Posts: 20
Joined: August 16, 2011
Location: Florida. USA

Re: automatic redirect to members page after open registrati

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

rwilki wrote: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...


You had a small syntax error in your code. Try this:

Code: Select all
<?php } elseif ($_GET['s2member_level_required'] === '0') { ?>
By registering now...
<?php } elseif ($_GET['s2member_level_required'] === '1') { ?>
Premium Access Pass...
<?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 RJGonzalez » August 17th, 2011, 3:22 am

ok, reading this post i found this,
Code: Select all
wp_redirect(S2MEMBER_LOGIN_WELCOME_PAGE_URL . '?first');

is that where i have to redirect to

S2MEMBER_LOGIN_WELCOME_PAGE_URL <-- being the original name i gave the page when i created corect
Always willing to help, securely at http://www.149host.com
User avatar
RJGonzalez
Registered User
Registered User
 
Posts: 20
Joined: August 16, 2011
Location: Florida. USA

Re: automatic redirect to members page after open registrati

Postby RJGonzalez » August 17th, 2011, 3:28 am

From this:

Code: Select all
<p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.', 'kubrick'), get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode(get_permalink())); ?></p>


To this:

Code: Select all
members-area <p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.', 'kubrick'), get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode(members-area())); ?></p>
Always willing to help, securely at http://www.149host.com
User avatar
RJGonzalez
Registered User
Registered User
 
Posts: 20
Joined: August 16, 2011
Location: Florida. USA

Re: automatic redirect to members page after open registrati

Postby seofeed » August 27th, 2011, 12:06 am

Hey Christian, here I am showing up in another thread :)

I tried this code and it's not working for my special redirection URL for subscribers (level 0).

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_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();
    }
}


It works, but it redirects to the URL for S2_Member_Level1. For example purposes, here's what my URL looks like on the Login Welcome Page box:

http://domain.com/download-%%current_user_level%%

Of course, upon login or clicking the Profile link it redirects to the proper page just not after user registration. I looked in s2member/includes/classes/constants.php.inc for another constant that handles the Special Redirection URL but the constant definition for S2MEMBER_LOGIN_WELCOME_PAGE_URL seems to handle that situation.

Not sure how to get this working. Thanks!
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 27th, 2011, 2:49 am

I see. I wonder if at this point in the code the user's S2MEMBER_LOGIN_WELCOME_PAGE_URL is not updated yet with the new level he got during registration.

You could try changing the redirection line in the hack to this

Code: Select all
        wp_redirect('http://domain.com/download-' . $vars['__refs']['level'] . '?first');
 


Let me know if it works. :)
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 seofeed » August 27th, 2011, 2:26 pm

Changing the redirect to that sends them to the right place but no role is assigned unfortunately. Role is marked as none
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: automatic redirect to members page after open registrati

Postby seofeed » August 27th, 2011, 2:27 pm

Forget to mention: since no role is assigned they are sent to the pricing options page for the correct download page.
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 27th, 2011, 10:50 pm

That's odd. You just changed the redirection line, right? Your code should look like this:

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('http://domain.com/download-' . $vars['__refs']['level'] . '?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 seofeed » August 27th, 2011, 11:09 pm

Yep that's it exactly.
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 28th, 2011, 2:36 am

Could you post your button's shortcode?
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 seofeed » August 28th, 2011, 10:51 am

Here it is:

[s2Member-Pro-PayPal-Form register="1" level="0" ccaps="" desc="" custom="domain.com" tp="0" tt="D" captcha="0" /]

Of course, changed custom to domain.com
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: automatic redirect to members page after open registrati

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

Thank you.

seofeed wrote:Forget to mention: since no role is assigned they are sent to the pricing options page for the correct download page.


So the user's account is created but no role assigned to it? I just tried the hack for a level 0 user and another at level 1 and both had the role assigned correctly.

Was this problem also happening when you used S2MEMBER_LOGIN_WELCOME_PAGE_URL in the redirection or only after you changed it?
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 seofeed » August 29th, 2011, 9:51 pm

After I changed it. It worked before but sent them to the wrong page. That's why the redirect change. After testing again with the updated code it sends to the wrong page (level 1 page) and doesn't assign a role either.
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 30th, 2011, 11:48 am

I don't know why that could be. Why not, instead of having a separate login welcome page for each level, have just one page and use conditionals there to show different things to each level?
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 seofeed » August 30th, 2011, 11:57 am

Goal tracking would be screwy. I feel like this error and the other one are probably related in some way. I know they are completely different but it's the only two issues I'm having and no one else is having them.
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 30th, 2011, 6:19 pm

That's a possibility.

And I understand what you mean about goal tracking...

Could you try the hack with the redirection like this?

Code: Select all
        wp_redirect('http://domain.com/download-' . S2MEMBER_CURRENT_USER_ACCESS_LEVEL . '?first');
 


Or how about using a Login Welcome page and there have a redirect to the welcome page for each level?

Code: Select all
<?php header('Location: http://domain.com/download-' . S2MEMBER_CURRENT_USER_ACCESS_LEVEL); ?>
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 seofeed » August 30th, 2011, 8:51 pm

With that hack, the result is the same. No role assigned. The login welcome with redirect is a good idea and can use that if all else fails.
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » August 31st, 2011, 10:51 pm

If the header function doesn't work, you can redirect with JavaScript like this:

Code: Select all
<?php echo '<script type="text/javascript">window.location = \'http://domain.com/download-' . S2MEMBER_CURRENT_USER_ACCESS_LEVEL . '\';</script>'; ?>

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 seofeed » September 12th, 2011, 12:00 am

Ok, got back to dealing with this and this code magically works:

Notice the change from ws_plugin__s2member_during_configure_user_registration to ws_plugin__s2member_during_configure_user_registration_front_side_free

That's what did it.

Code: Select all

add_action('ws_plugin__s2member_during_configure_user_registration_front_side_free', '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('http://domain.com/download-' . $vars['__refs']['level']);
        exit();
    }
}



The only problem I'm still dealing with that process list servers isn't working. I'm guessing it will look something like this in the middle of that above code but I can't get it working:

Code: Select all
add_filter("ws_plugin__s2member_process_list_servers", "__return_true");


Thanks!
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: automatic redirect to members page after open registrati

Postby seofeed » September 12th, 2011, 12:22 am

Another thing is the admin notification email doesn't go out. Kinda concerns me that all of the routines that are supposed to be ran aren't being run with that hack. That codebase you guys have is gigantic and extremely well laid out and want to make sure nothing is missed.
User avatar
seofeed
Registered User
Registered User
 
Posts: 51
Joined: August 10, 2011

Re: automatic redirect to members page after open registrati

Postby bsowards » September 14th, 2011, 4:25 pm

I do think it would be valuable to have more control over this process. Anything you could provide ont his Cristian?
User avatar
bsowards
Experienced User
Experienced User
 
Posts: 25
Joined: August 24, 2011

Re: automatic redirect to members page after open registrati

Postby cexpert » September 20th, 2011, 11:07 pm

It looks like a great hack, but would anybody be so kind to show me how to actually implement this?
I mean you can't exactly redirect the user to the /wp-content/mu-plugins/s2hacks.php URL by using the success= in the paypal button shortcode can't we?

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. :)


Thank a lot for your time.

Claude LaBadie
User avatar
cexpert
Registered User
Registered User
 
Posts: 3
Joined: September 11, 2011

Re: automatic redirect to members page after open registrati

Postby Cristián Lávaque » September 25th, 2011, 11:13 pm

Claude, you place that hack in the dir/file mentioned and it'll work without needing the user to do anything. He registers and gets logged in automatically.

Guys, sorry, I haven't been able to look into the admin notification and the list servers routine yet. I'll do it as soon as possible. Thanks for your patience!
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

Previous

Return to s2Member Plugin

Who is online

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

cron