Skip to:
Content

BuddyPress.org


Ignore:
File:
1 edited

Legend:

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

    r5052 r5203  
    141141
    142142                // Auto join this user if they are not yet a member of this group
    143                 if ( $bp->groups->auto_join && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     143                if ( bp_groups_auto_join() && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
    144144                    groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
    145145
     
    338338                    $error_message = __( "You have been banned from this group.", 'buddypress' );
    339339
    340                 } elseif ( $bp->groups->auto_join && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
     340                } elseif ( bp_groups_auto_join() && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    341341                    // Auto join this user if they are not yet a member of this group
    342342                    groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
     
    641641                    return false;
    642642
     643                // Stop sole admins from abandoning their group
     644                $group_admins = groups_get_group_admins( $bp->groups->current_group->id );
     645                if ( 1 == count( $group_admins ) && $group_admins[0]->user_id == $user_id )
     646                    bp_core_add_message( __( 'This group must have at least one admin', 'buddypress' ), 'error' );
     647
    643648                // Demote a user.
    644                 if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) )
     649                elseif ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) )
    645650                    bp_core_add_message( __( 'There was an error when demoting that user, please try again', 'buddypress' ), 'error' );
    646651                else
Note: See TracChangeset for help on using the changeset viewer.