[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Groups: Join action 4 * 5 * @package BuddyPress 6 * @subpackage GroupActions 7 * @since 3.0.0 8 */ 9 10 /** 11 * Catch and process "Join Group" button clicks. 12 * 13 * @since 1.0.0 14 * 15 * @return bool 16 */ 17 function groups_action_join_group() { 18 19 if ( !bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action( 'join' ) ) 20 return false; 21 22 // Nonce check. 23 if ( !check_admin_referer( 'groups_join_group' ) ) 24 return false; 25 26 $bp = buddypress(); 27 28 // Skip if banned or already a member. 29 if ( !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) && !groups_is_user_banned( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) { 30 31 // User wants to join a group that requires an invitation to join. 32 if ( ! bp_current_user_can( 'groups_join_group', array( 'group_id' => $bp->groups->current_group->id ) ) ) { 33 if ( !groups_check_user_has_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) { 34 bp_core_add_message( __( 'There was an error joining the group.', 'buddypress' ), 'error' ); 35 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 36 } 37 } 38 39 // User wants to join any group. 40 if ( !groups_join_group( $bp->groups->current_group->id ) ) 41 bp_core_add_message( __( 'There was an error joining the group.', 'buddypress' ), 'error' ); 42 else 43 bp_core_add_message( __( 'You joined the group!', 'buddypress' ) ); 44 45 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 46 } 47 48 /** 49 * Filters the template to load for the single group screen. 50 * 51 * @since 1.0.0 52 * 53 * @param string $value Path to the single group template to load. 54 */ 55 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); 56 } 57 add_action( 'bp_actions', 'groups_action_join_group' );
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 |