If you’re not on the members page or a profile page, I don’t think bp_displayed_user_id() will work.
You need to get all the member ids and then loop thru them, something like:
friends_check_friendships(bp_loggedin_user_id(), $ids[$i])
You’re doing this on a custom WP page?
Rather than use ‘allow php in html’, you should create a template and assign it to that page.
You know that /members/mattnetusa/friends/ lists your friends ?
Thanks for your response! okay maybe I am stating this wrong. I have a list of entries showing various user ids as one of the fields. In the next field I simply want to show are these entries from a friend or not so that I can filter them to only show me entries from my friends. Does that make sense. I thought the purpose of the friends_check_friendships function was to compare to user ids to see if their is a relationship between them and return ‘true’ or ‘false’? Also, are the user ids in buddypress friendships the same user ids in wordpress users without buddypress? For instance the two I am comparing are user_id=1 and user_id=2, so in the function, it should result in friends_check_friendships(1,2) = true right?
Try
bp_is_friend( $user_id )
It will check to see if the logged_in user is a friend of $user_id
Returns – ‘is_friend’, ‘not_friends’, ‘pending’.
Thanks. okay so I can get that working now to give me a result at least, but I have set it up in my functions.php file as a shortcode that I can call, but how do I feed it the variable of the $user_id when using shortcode? like [shortcodename id=2]
?
I have added the line add_shortcode('shortcodename', 'bp_is_friend');
to functions.php and calling it with [shortcodename]
.
Again thanks for the help…feellike I’m finally getting somewhere towards my goal…
add_shortcode('mx-check-if-friends','mx_friends_check_friendship');
function mx_friends_check_friendship( $atts ){
extract(shortcode_atts(array(
'user_id' => '',
'possible_friend_id' => '',
), $atts ) );
return friends_check_friendship( $user_id, $possible_friend_id );
}
OK, I’m not sure if this is exactly correct but it is returning a 1 if friends and a blank if not…basically wrote a shortcode that points to a function that I can provide variables in that in turn then calls the friends_check_friendship function. Anything blatantly wrong with this method?