Page 2 of 2
Re: automatic redirect to members page after open registrati
Posted:
August 17th, 2011, 3:14 am
by RJGonzalez
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.
Re: automatic redirect to members page after open registrati
Posted:
August 17th, 2011, 3:15 am
by Cristián Lávaque
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 } ?>
Re: automatic redirect to members page after open registrati
Posted:
August 17th, 2011, 3:22 am
by RJGonzalez
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
Re: automatic redirect to members page after open registrati
Posted:
August 17th, 2011, 3:28 am
by RJGonzalez
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>
Re: automatic redirect to members page after open registrati
Posted:
August 27th, 2011, 12:06 am
by seofeed
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!
Re: automatic redirect to members page after open registrati
Posted:
August 27th, 2011, 2:49 am
by Cristián Lávaque
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.
Re: automatic redirect to members page after open registrati
Posted:
August 27th, 2011, 2:26 pm
by seofeed
Changing the redirect to that sends them to the right place but no role is assigned unfortunately. Role is marked as none
Re: automatic redirect to members page after open registrati
Posted:
August 27th, 2011, 2:27 pm
by seofeed
Forget to mention: since no role is assigned they are sent to the pricing options page for the correct download page.
Re: automatic redirect to members page after open registrati
Posted:
August 27th, 2011, 10:50 pm
by Cristián Lávaque
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();
}
}
?>
Re: automatic redirect to members page after open registrati
Posted:
August 27th, 2011, 11:09 pm
by seofeed
Yep that's it exactly.
Re: automatic redirect to members page after open registrati
Posted:
August 28th, 2011, 2:36 am
by Cristián Lávaque
Could you post your button's shortcode?
Re: automatic redirect to members page after open registrati
Posted:
August 28th, 2011, 10:51 am
by seofeed
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
Re: automatic redirect to members page after open registrati
Posted:
August 29th, 2011, 12:30 pm
by Cristián Lávaque
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?
Re: automatic redirect to members page after open registrati
Posted:
August 29th, 2011, 9:51 pm
by seofeed
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.
Re: automatic redirect to members page after open registrati
Posted:
August 30th, 2011, 11:48 am
by Cristián Lávaque
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?
Re: automatic redirect to members page after open registrati
Posted:
August 30th, 2011, 11:57 am
by seofeed
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.
Re: automatic redirect to members page after open registrati
Posted:
August 30th, 2011, 6:19 pm
by Cristián Lávaque
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); ?>
Re: automatic redirect to members page after open registrati
Posted:
August 30th, 2011, 8:51 pm
by seofeed
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.
Re: automatic redirect to members page after open registrati
Posted:
August 31st, 2011, 10:51 pm
by Cristián Lávaque
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>'; ?>
Re: automatic redirect to members page after open registrati
Posted:
September 12th, 2011, 12:00 am
by seofeed
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!
Re: automatic redirect to members page after open registrati
Posted:
September 12th, 2011, 12:22 am
by seofeed
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.
Re: automatic redirect to members page after open registrati
Posted:
September 14th, 2011, 4:25 pm
by bsowards
I do think it would be valuable to have more control over this process. Anything you could provide ont his Cristian?
Re: automatic redirect to members page after open registrati
Posted:
September 20th, 2011, 11:07 pm
by cexpert
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
Re: automatic redirect to members page after open registrati
Posted:
September 25th, 2011, 11:13 pm
by Cristián Lávaque
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!