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 used the "Edit Author Slug" plugin to change the author base to /newbase .

In the functions.php file, I added a new node to the toolbar (View Profile) that when clicked points to ../newbase/johndoe (johndoe is the author slug)

I'm using the author.php page as the /profile and will show some user information.

If the user is logged in and clicks in the "View Profile" link, I have no problem. Inside author.php I can use $current_user->user_login and get all the information.

My problem is for those not logged in or, let say I have a page displaying users and I click on their link which looks like .../profile/mrsmith - I cannot use $current_user .

I would like to somehow pass a variable (maybe query_vars, I don't know) to author.php (/profile) or to extract the "mrsmith" from the URL and the inside author.php I can look up that user in the database and show the data I want.

I appreciate your help on this. Maybe is very easy but I have struggle for 2 days and have tried multiple things and can't figure it out.

share|improve this question

You can get the queried author in author.php with get_queried_object():

$author = get_queried_object();
echo $author->ID;

$author_data = get_object_vars( $author->data );

echo $author_data['display_name'];
echo $author_data['user_url'];
echo $author_data['user_email'];
share|improve this answer
Hello Milo, I was able to get it to work with a piece of your code. That is $author = get_queried_object(); - with that I go the id and plot it into get_userdata( $userid ) - I did't have to mess up with anything else. Thank you very much. – Joe Jul 14 '12 at 4:10
Joe, you should mark the answer as accepted. Please read the About and FAQ pages to learn how this site works. – Ian Dunn Jul 14 '12 at 8:48

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.