How do I get the user id of my users dynamically from a custom function? As in not just the id of the currently logged in user but all users depending on which user's profile that you're on. Any help would be greatly appreciated.

  • Your question says "logged out" - logged out users do not have a user ID. Can you clarify your question?
    – WebElaine
    May 17, 2018 at 15:28
  • I've updated the question, sorry for the confusion
    – Matt H
    May 17, 2018 at 15:35

1 Answer 1


You can use get_the_author_meta() which returns the requested data of the author of the current post. If you're on the author archive page (e.g. author.php) that will be the ID of the user whose profile you are on.

get_the_author_meta( 'ID' );
  • Unfortunately that doesn't work as I'm trying to echo the id from a function on a custom functions page as I'm trying to access the information through ajax.
    – Matt H
    May 17, 2018 at 18:15

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.