Menu Button that link to different pages for unique user?

If you want to do something like a “Back to previous page”-link that will probably not work with the WP menu system.

But you could modify/add your theme and use $_SERVER['HTTP_REFERER'] (PHP manual) to link back to the site, where the user clicked the link to the actual page. But that information can also be altered or not be available due to privacy settings/plugins or other things, so make sure to catch that.


Update: Thanks to the much clearer information from the comments, you could do this.

  1. Create a page template, called “Redirect to User Page” or something like that. Have a look here to see how that works.
  2. Put this in the template file besides the necessary pieces (you might need to adjust it, to fit your needs):

if(is_user_logged_in()) {
$user_info = get_userdata(get_current_user_id());
$url="http:// www. example. com/users/".$user_info->user_login."https://wordpress.stackexchange.com/";
$string = '< script type="text/javascript" >';
$string .= 'window.location = "' . $url . '"';
$string .= '< /script >';
}

This will first check if a user is logged in, then retrieve his user data and finally redirect to a (sub)page you define where his login name is the permalink.

  1. Set up a page that uses the custom page template and choose a nice permalink for it.

You can then link to that page in a menu. You should furthermore define an else-case or arrange to not show that link when you are not logged in.

Make sure to look up the functions I used here. Can´t post more than two links right now, but you should really understand what this does and why it does, otherwise you won´t have much fun using it.