Tagged: Add friend button hide
Hi,
As the user reject the friendship. The button changed into “Add friend” for both users. I want to hide this button after rejecting the friendship at the sender end (which initiate or who send the friend request). The person who reject the friendship should see the “Add friend” Button only.Please help.
Hello Swati,
Try the following code in your bp-custom.php file and let me know if it works or not
function buddydev_custom_send_notification_on_friendship_rejection( $friendship_id, BP_Friends_Friendship $friendship ) { add_user_meta( $friendship->initiator_user_id, '_rejected_by', $friendship->friend_user_id ); } add_action( 'friends_friendship_rejected', 'buddydev_custom_send_notification_on_friendship_rejection', 10, 2 ); function buddydev_hide_add_friend_button( $button ) { $displayed_user_id = bp_displayed_user_id(); $user_id = ( $displayed_user_id ) ? $displayed_user_id : bp_get_member_user_id(); $rejected_by = get_user_meta( bp_loggedin_user_id(), '_rejected_by' ); if ( in_array( $user_id, $rejected_by ) ) { return ''; } return $button; } add_filter('bp_get_add_friend_button', 'buddydev_hide_add_friend_button');
Thank You
RaviHi Ravi Ji,
Thank you so mcuh for the response.
It is not working.
as I have already used the function “buddydev_custom_send_notification_on_friendship_rejection” as suggested by Brajesh Ji in query #8743, So the error showing that you cann’t redeclare this function again.#8743 code is given below (It is working for sending the email message after rejection of friendship)
function buddydev_custom_send_notification_on_friendship_rejection( $friendship_id, BP_Friends_Friendship $friendship ) {$initiator_user = get_user_by(‘id’, $friendship->initiator_user_id );
$rejected_by_user = get_user_by( ‘id’, $friendship->friend_user_id );$message =<<<‘EOT’
Hi %1$s,
%2$s has rejected your friendship request.Team
Xyz Site
EOT;
$message = sprintf( $message, $initiator_user->display_name, $rejected_by_user->display_name );
wp_mail($initiator_user->user_email, “Friendship Rejection”, $message );}
add_action( ‘friends_friendship_rejected’, ‘buddydev_custom_send_notification_on_friendship_rejection’, 10, 2 );Please look in this code again. Looking for your help.
Thank you so much
The topic ‘ [Resolved] Hide "Add friend" Button after rejecting the friendship (only at the sender end’ is closed to new replies.