-
Author
-
April 9, 2015 at 16:16 #53771bhavyaParticipant
Hi,
I want to use certain buddypress functionality while displaying the wordpress posts.
Specifically – I am trying to use bp_displayed_user_id/$bp->displayed_user->id inside content.php (in my child theme). But bp_displayed_user_id returns 0 inside content.php
Can you please let me know how i could do this?
Thanks.April 9, 2015 at 16:26 #53775sharmstrModeratorhave you declared
global $bp;
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
April 9, 2015 at 16:28 #53776sharmstrModeratorWait. bp_displayed_user_id is for use within a profile. Basically its what user is being displayed. Do you need something like logged in user instead?
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
April 9, 2015 at 16:35 #53778bhavyaParticipantYes I have declared global $bp.
Basically, I want to display buddypress follow button in the author meta.
So I need both displayed user id & logged in user. And i want bp_displayed_user_id to be set correctly at this stage (to enable follow button) but it is not.
I am able to use bp_loggedin_user_id to get the logged in user.April 9, 2015 at 16:49 #53780sharmstrModeratorYou cant use bp_displayed_user_id to return the author id from a post because as I said before, you’re not in a buddypress profile.. You need to use https://codex.wordpress.org/Function_Reference/the_author_meta
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
April 9, 2015 at 17:10 #53782bhavyaParticipantBut I am able to use bp_displayed_user_id inside post-content-small.php which basically lists all the posts. That is why I am wondering if I am missing something while displaying the individual posts?
Can I somehow extend buddypress profile to use in content.php?
Thanks!PS: If i use the author meta i will have to make a lot of changes in my existing function so keeping it as a last resort.
April 9, 2015 at 17:43 #53788sharmstrModeratorI dont understand why you’d have to make a bunch of changes. All you’re looking to get is the userid of the author. Once you have that, you can use it in any buddypress function call.
So instead of $bp->displayed_user->id, use get_the_author_meta( ‘ID’ );
If you look at the Kleo author meta functions, it uses get_the_author_meta( ‘ID’ ) to call buddypress functions as well. That’s because you cant use $bp->displayed_user->id to get the author id.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
April 9, 2015 at 19:17 #53808bhavyaParticipanthmmm..Inside my function am actually using bp_displayed_user_id in some places to perform certain checks as to display the follow button or not & the same function is called from different places.
Anyway, I will just work around that.
Thanks for your help! 🙂 -
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.