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.

1 Answer 1


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'];
  • 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
    Commented Jul 14, 2012 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
    Commented Jul 14, 2012 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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