[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Groups: Single group "Send Invites" screen handler 4 * 5 * @package BuddyPress 6 * @subpackage GroupsScreens 7 * @since 3.0.0 8 */ 9 10 /** 11 * Handle the display of a group's Send Invites page. 12 * 13 * @since 1.0.0 14 */ 15 function groups_screen_group_invite() { 16 17 if ( !bp_is_single_item() ) 18 return false; 19 20 $bp = buddypress(); 21 22 if ( bp_is_action_variable( 'send', 0 ) ) { 23 24 if ( !check_admin_referer( 'groups_send_invites', '_wpnonce_send_invites' ) ) 25 return false; 26 27 if ( !empty( $_POST['friends'] ) ) { 28 foreach( (array) $_POST['friends'] as $friend ) { 29 groups_invite_user( array( 'user_id' => $friend, 'group_id' => $bp->groups->current_group->id ) ); 30 } 31 } 32 33 // Send the invites. 34 groups_send_invites( array( 'group_id' => $bp->groups->current_group->id ) ); 35 bp_core_add_message( __('Group invites sent.', 'buddypress') ); 36 37 /** 38 * Fires after the sending of a group invite inside the group's Send Invites page. 39 * 40 * @since 1.0.0 41 * 42 * @param int $id ID of the group whose members are being displayed. 43 */ 44 do_action( 'groups_screen_group_invite', $bp->groups->current_group->id ); 45 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 46 47 } elseif ( !bp_action_variable( 0 ) ) { 48 49 /** 50 * Filters the template to load for a group's Send Invites page. 51 * 52 * @since 1.0.0 53 * 54 * @param string $value Path to a group's Send Invites template. 55 */ 56 bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/single/home' ) ); 57 58 } else { 59 bp_do_404(); 60 } 61 } 62 63 /** 64 * Process group invitation removal requests. 65 * 66 * Note that this function is only used when JS is disabled. Normally, clicking 67 * Remove Invite removes the invitation via AJAX. 68 * 69 * @since 2.0.0 70 */ 71 function groups_remove_group_invite() { 72 if ( ! bp_is_group_invites() ) { 73 return; 74 } 75 76 if ( ! bp_is_action_variable( 'remove', 0 ) || ! is_numeric( bp_action_variable( 1 ) ) ) { 77 return; 78 } 79 80 if ( ! check_admin_referer( 'groups_invite_uninvite_user' ) ) { 81 return false; 82 } 83 84 $friend_id = intval( bp_action_variable( 1 ) ); 85 $group_id = bp_get_current_group_id(); 86 $message = __( 'Invite successfully removed', 'buddypress' ); 87 $redirect = wp_get_referer(); 88 $error = false; 89 90 if ( ! bp_groups_user_can_send_invites( $group_id ) ) { 91 $message = __( 'You are not allowed to send or remove invites', 'buddypress' ); 92 $error = 'error'; 93 } elseif ( groups_check_for_membership_request( $friend_id, $group_id ) ) { 94 $message = __( 'The member requested to join the group', 'buddypress' ); 95 $error = 'error'; 96 } elseif ( ! groups_uninvite_user( $friend_id, $group_id ) ) { 97 $message = __( 'There was an error removing the invite', 'buddypress' ); 98 $error = 'error'; 99 } 100 101 bp_core_add_message( $message, $error ); 102 bp_core_redirect( $redirect ); 103 } 104 add_action( 'bp_screens', 'groups_remove_group_invite' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |