Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to get the viewing profle's (another user's profile that current user is viewing) user_id

is there any shortcode or function available for it?

Thanks in advance.

share|improve this question

1 Answer 1

Maybe you need this: bp_displayed_user_id().

Also see playing with the user’s ID in different contexts in BuddyPress documentation.

share|improve this answer
This function is not working for me, I put this into 'functions.php' and always it returning 0. –  Ka Ba Su Jul 31 '12 at 6:17
probably the portion of code where you are using it doesn't run when a user profile is displayed; so, it makes sense the return value is 0. For istance, using that function in the homepage or in the member directory or some other page would return 0 for sure. Is this your case? –  blake83 Jul 31 '12 at 8:30
hmmm NO, I've added it to function.php, as you may aware it will be executed every time the page refreshes or loads. And the test code I,ve put as below , echo "<script type='text/javascript'>alert(".bp_displayed_user_id().");</script>"; –  Ka Ba Su Jul 31 '12 at 9:10
uhm, I was not talking about that...can you paste a portion of the code? Maybe that will help... –  blake83 Jul 31 '12 at 9:29
Tha it is the coding part, Its not working, Thank for your time and help @blake83 –  Ka Ba Su Jul 31 '12 at 11:12

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.