Skip to:
Content

BuddyPress.org


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5/bp-groups/bp-groups-actions.php

    r4961 r5203  
    244244    // User wants to leave any group
    245245    if ( groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    246         if ( !groups_leave_group( $bp->groups->current_group->id ) ) {
     246
     247        // Stop sole admins from abandoning their group
     248        $group_admins = groups_get_group_admins( $bp->groups->current_group->id );
     249        if ( 1 == count( $group_admins ) && $group_admins[0]->user_id == $bp->loggedin_user->id )
     250            bp_core_add_message( __( 'This group must have at least one admin', 'buddypress' ), 'error' );
     251
     252        elseif ( !groups_leave_group( $bp->groups->current_group->id ) )
    247253            bp_core_add_message( __( 'There was an error leaving the group.', 'buddypress' ), 'error' );
    248         } else {
     254        else
    249255            bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
    250         }
     256
    251257        bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    252258    }
Note: See TracChangeset for help on using the changeset viewer.