[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Member Invitations: Bulk-manage action handler 4 * 5 * @package BuddyPress 6 * @subpackage MembersActions 7 * @since 8.0.0 8 */ 9 10 /** 11 * Handles bulk management (resend, cancellation) of invitations. 12 * 13 * @since 8.0.0 14 * 15 * @return bool 16 */ 17 function bp_members_invitations_action_bulk_manage() { 18 19 // Bail if not the user's invitations screen. 20 if ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) { 21 return false; 22 } 23 24 // Get the parameters. 25 $action = ! empty( $_POST['invitation_bulk_action'] ) ? $_POST['invitation_bulk_action'] : ''; 26 $nonce = ! empty( $_POST['invitations_bulk_nonce'] ) ? $_POST['invitations_bulk_nonce'] : ''; 27 $invitations = ! empty( $_POST['members_invitations'] ) ? $_POST['members_invitations'] : ''; 28 29 // Bail if no action or no IDs. 30 if ( ( ! in_array( $action, array( 'cancel', 'resend' ), true ) ) || empty( $invitations ) || empty( $nonce ) ) { 31 return false; 32 } 33 34 // Check the nonce. 35 if ( ! wp_verify_nonce( $nonce, 'invitations_bulk_nonce' ) ) { 36 bp_core_add_message( __( 'There was a problem managing your invitations.', 'buddypress' ), 'error' ); 37 return false; 38 } 39 40 $invitations = wp_parse_id_list( $invitations ); 41 42 // Cancel or resend depending on the user 'action'. 43 switch ( $action ) { 44 case 'cancel' : 45 $success = 0; 46 foreach ( $invitations as $invite_id ) { 47 if ( bp_members_invitations_delete_by_id( $invite_id ) ) { 48 $success++; 49 } 50 } 51 $message = sprintf( 52 esc_html( 53 /* translators: %d: the number of invitations that were canceled. */ 54 _n( '%d invitation was canceled.', '%d invitations were canceled.', $success, 'buddypress' ) 55 ), 56 $success 57 ); 58 bp_core_add_message( $message ); 59 break; 60 61 case 'resend' : 62 $success = 0; 63 foreach ( $invitations as $invite_id ) { 64 if ( bp_members_invitation_resend_by_id( $invite_id ) ) { 65 $success++; 66 } 67 } 68 $message = sprintf( 69 esc_html( 70 /* translators: %d: the number of invitations that were resent. */ 71 _n( '%d invitation was resent.', '%d invitations were resent.', $success, 'buddypress' ) 72 ), 73 $success 74 ); 75 bp_core_add_message( $message ); 76 break; 77 } 78 79 // Redirect. 80 bp_core_redirect( bp_displayed_user_domain() . bp_get_members_invitations_slug() . '/' . bp_current_action() . '/' ); 81 } 82 add_action( 'bp_actions', 'bp_members_invitations_action_bulk_manage' );
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 |