Skip to:
Content

BuddyPress.org

Changeset 950


Ignore:
Timestamp:
01/28/2009 08:17:47 PM (16 years ago)
Author:
apeatling
Message:

Added restriction on group admins leaving a group of which they are the only administrator. Fixes #404

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r949 r950  
    534534    if ( $is_single_group ) {
    535535        if ( isset($bp['action_variables']) && $bp['action_variables'][0] == 'yes' ) {
     536           
     537            // Check if the user is the group admin first.
     538            if ( groups_is_group_admin( $bp['loggedin_userid'], $group_obj->id ) ) {
     539                bp_core_add_message(  __('As the only group administrator, you cannot leave this group.', 'buddypress'), 'error' );
     540                bp_core_redirect( bp_group_permalink( $group_obj, false) );
     541            }
     542           
    536543            // remove the user from the group.
    537544            if ( !groups_leave_group( $group_obj->id ) ) {
     
    542549                bp_core_redirect( $bp['loggedin_domain'] . $bp['groups']['slug'] );
    543550            }
     551           
    544552        } else if ( isset($bp['action_variables']) && $bp['action_variables'][0] == 'no' ) {
     553           
    545554            bp_core_redirect( bp_group_permalink( $group_obj, false) );
     555       
    546556        } else {
     557       
    547558            do_action( 'groups_screen_group_leave', $group_obj->id );
    548559           
    549560            // Show leave group page
    550561            bp_core_load_template( 'groups/leave-group-confirm' );
     562       
    551563        }
    552564    }
     
    16211633    if ( !$user_id )
    16221634        $user_id = $bp['loggedin_userid'];
     1635   
     1636    // Admins cannot leave a group, that is until promotion to admin support is implemented.
     1637    if ( groups_is_group_admin( $user_id, $group_id ) )
     1638        return false;
    16231639       
    16241640    // This is exactly the same as deleting and invite, just is_confirmed = 1 NOT 0.
Note: See TracChangeset for help on using the changeset viewer.