Skip to:
Content

BuddyPress.org

Ticket #2336: join_leave_group_fixes.diff

File join_leave_group_fixes.diff, 1.6 KB (added by boonebgorges, 15 years ago)
  • bp-groups.php

     
    11111111        if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join' )
    11121112                return false;
    11131113
     1114        if ( !check_admin_referer( 'groups_join_group' ) )
     1115                return false;
     1116               
    11141117        // user wants to join a group
    11151118        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 ) ) {
    11161119                if ( !groups_join_group($bp->groups->current_group->id) ) {
     
    11251128}
    11261129add_action( 'wp', 'groups_action_join_group', 3 );
    11271130
     1131function groups_action_leave_group() {
     1132        global $bp;
     1133
     1134        if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'leave-group' )
     1135                return false;
     1136
     1137        if ( !check_admin_referer( 'groups_leave_group' ) )
     1138                return false;
     1139               
     1140        // user wants to leave a group
     1141        if ( groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
     1142                if ( !groups_leave_group($bp->groups->current_group->id) ) {
     1143                        bp_core_add_message( __('There was an error leaving the group.', 'buddypress'), 'error' );
     1144                } else {
     1145                        bp_core_add_message( __('You left the group.', 'buddypress') );
     1146                }
     1147                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
     1148        }
     1149
     1150        bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
     1151}
     1152add_action( 'wp', 'groups_action_leave_group', 3 );
     1153
    11281154function groups_action_sort_creation_steps() {
    11291155        global $bp;
    11301156