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.
1 Answer
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 HCommented May 17, 2018 at 18:15