WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I hope this problem does not have too complicated of a solution. I also hope it isn't too easy so I don't feel like a fool for not figuring it out :)

On my website, (Wordpress), I have Peter's redirect plugin that redirects users after login to their specified personal page (not profile.php). This is great.

However, after leaving their page, the only way to get back to it is to type the address to the page in the address bar, or logout/login again.

Is there a way I can create a normal link, that will recognize the currently logged in user, and redirect them accordingly to their personal page?

I know this may be basic, but I have search relentlessly through various sites, and other venues to locate an answer, and cannot seem to find one. I imagine it is because I am missing a 'key' word in my search, or it is so basic no one feels it needs to be covered.

I also looked at the source code for the a fore mentioned redirect plugin to find this:

$current_user = wp_get_current_user();
$redirect_to = admin_url();
$redirect_url = redirect_wrapper( $redirect_to, '', $current_user );
wp_redirect( $redirect_url );

I know this probably means something to someone, would this work? If so, where could/should I put it to get the desired results?

share|improve this question
Try adding a <a href="<?php echo $redirect_url; ?>">Some Link Text</a> and see if it works. You don't need the wp_redirect(...) and die() parts. – akTed Feb 11 '13 at 3:34
Give us the code of the 'redirect_wrapper' function. That's where the URL you want is being formed, apparently. – Tomas Buteler Feb 11 '13 at 14:59
up vote 1 down vote accepted

Thank you so much for the responses. Using both of the ideas received I started to play a little with the code, although I was not sure what to do with them.

I came up with a solution that works very well for me, I created a new template in my theme called 'redirect.php'. At the very beginning of the page template I inserted the code found in Peter's login Redirect.

$current_user = wp_get_current_user();
$redirect_to = admin_url();
$redirect_url = redirect_wrapper( $redirect_to, '', $current_user );
wp_redirect( $redirect_url );

Then I added a link to that new template in regular html. When clicked, it automatically looks up the user, and sends the user to their page that is listed in Peter's login redirect.

What you need for this obviously is; Peter's login/redirect plugin, and to create your own blank template with the code snippet above. Thanks again for everyone, it helped me realize where to look and what to put.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.