[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Friends: Remove action. 4 * 5 * @package BuddyPress 6 * @subpackage FriendsActions 7 * @since 3.0.0 8 */ 9 10 /** 11 * Catch and process Remove Friendship requests. 12 * 13 * @since 1.0.1 14 */ 15 function friends_action_remove_friend() { 16 if ( ! bp_is_friends_component() || ! bp_is_current_action( 'remove-friend' ) ) { 17 return false; 18 } 19 20 $potential_friend_id = (int) bp_action_variable( 0 ); 21 if ( ! $potential_friend_id ) { 22 return false; 23 } 24 25 if ( bp_loggedin_user_id() === $potential_friend_id ) { 26 return false; 27 } 28 29 $friendship_status = BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), $potential_friend_id ); 30 31 if ( 'is_friend' === $friendship_status ) { 32 33 if ( ! check_admin_referer( 'friends_remove_friend' ) ) { 34 return false; 35 } 36 37 if ( ! friends_remove_friend( bp_loggedin_user_id(), $potential_friend_id ) ) { 38 bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' ); 39 } else { 40 bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) ); 41 } 42 } elseif ( 'not_friends' === $friendship_status ) { 43 bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' ); 44 } else { 45 bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' ); 46 } 47 48 bp_core_redirect( wp_get_referer() ); 49 50 return false; 51 } 52 add_action( 'bp_actions', 'friends_action_remove_friend' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |