I’m working on a Buddypress / WordPress site, and using
get_queried_object()->ID;
to grab the user’s ID, but I get different results on different pages. I’ve gotten 47, 59, and 2. It should be 1 since I’m the admin. Any idea why it changes?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Probably you are looking for get_current_user_id() function, not get_queried_object() function. get_queried_object() retrieve the currently-queried object. Instead you should use get_current_user_id( )
In order to info about the logged in user try