I'm trying to place an "Add Friend" button outside of the members page, inside a loop, so the button appears next to the author's avatar in a post. I tried adding ;
<?php if ( bp_is_active( 'friends' ) ) { ?>
<?php bp_add_friend_button( $user_ids['users'][$i]->id ) ?>
<?php } ?>
Inside the loop but it didn't return any results. Then I placed the following action hook in functions.php, it displayed the button inside the loop but once clicked, all the buttons in the post list got clicked as well.
add_action( ‘the_content’, ‘bp_add_friend_button’, 5 );
So now I'm stuck. I thought, adding a template tag inside the template would work since it had worked for "Send Message" button.