getting the redirect URL for a specific user | Peter's Login Redirect | Forum

Back to the login redirect plugin page

Please consider registering

Log In

Lost password?
Advanced Search

— Forum Scope —


— Match —


— Forum Options —


Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
getting the redirect URL for a specific user
March 12, 2011
1:55 pm

I'd like to have a link on my blog that returns a user to the page they were originally redirected to when they logged in -- essentially, a home button that changes the link depending on the user. Is there a function that I can pass the current user's username into, and get the redirect URL in return?


March 12, 2011
7:15 pm
Forum Posts: 841

Yes, that is what the redirect_to_front_page() function does. You pass it 3 variables, in this order:

$redirect_to: the default redirect link you want if no rules match
$requested_redirect_to: just pass it an empty string; this variable it not used
$user: the current WordPress user object (if you don't already have it, I think it can be fetched with the function wp_get_current_user()

March 13, 2011
12:47 pm

Awesome, thanks for your help!