Jump to content
Sign in to follow this  
tperkins

How to change registration redirect for logged-in users?

Recommended Posts

tperkins

Our site uses PlatformPro. Currently if a user who is already logged-in tries to go to the registration page they are redirected to the home page. How can we change this to a different page?

Share this post


Link to post
Share on other sites
Rob
I use this... http://www.theblog.ca/wplogin-redirect

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
tperkins
I already have redirects setup for after they log-in. I'm talking about if they are already logged-in and try to go to the registration page. Thanks.

Share this post


Link to post
Share on other sites
kastelic
can you provide a link to your site please? I don't know of a plugin that does this specifically, but with a bit of custom code and a hook i'm sure this could be accomplished. The code would look something like this: [code] if ( is_user_logged_in() ){ wp_redirect( 'http://www.example.com' ); exit; } [/code] but you would need a conditional to check if you were on the registration page first, thats why i need to see your site.

Share this post


Link to post
Share on other sites
Rob
Buddpress and bbPress do that by default and I believe WP too. The concept being that if you're already logged in they're registered, you don't need to register again. Hence my suggestion for a redirect because once someone tries to visit the registration page again, they could be redirected to wheresoever the site owner wants them to go, rather than the homepage. You can read about it here: http://codex.wordpress.org/Function_Reference/wp_register and http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/registration-link-redirects-to-home-page/

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
tperkins
There's already a redirect happening. It seems that WP has some code SOMEWHERE similar to what Kastelic wrote. I just need to find it, or find a hook/filter for it so I can change what it does. Or even better a setting that I can just change from home page to whatever I want :)

Share this post


Link to post
Share on other sites
kastelic
You can probably filter the wp_redirect() function somehow, its listed here http://codex.wordpress.org/Plugin_API/Filter_Reference but doesn't provide a page on it. I will mark for dev attention.

Share this post


Link to post
Share on other sites
Simon
You can filter the login page with registration_redirect filter.

Share this post


Link to post
Share on other sites
tperkins
Ok, I figured it out. I didn't need to find a hook for registration, I just needed to call my function before WP redirects a logged-in user to the home page. function registration_redirect() { global $_SERVER; if(is_user_logged_in() && $_SERVER['REQUEST_URI']=='/register'){ wp_redirect('http://www.sitename.com/page/'); exit; } } add_action( 'init', 'registration_redirect' );

Share this post


Link to post
Share on other sites
tperkins
Sorry the forum messed up the indenting :-S and I don't know how to set the thread to answered by my own comment.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×