Skip to:

Disable Leave Group on Specific Groups

  • Avatar of tbhozie


    Hello all,

    This might be a weird question – but I will try to explain the best I can – Basically I want to disable the option to leave the group (only on specific groups). The reason is because when a user registers for my site they have to select the location of where they are from which then puts them into that group accordingly, but I do not want them to be able to leave the group because this is how the content is filtered.

    I have been looking at this block of code -
    `if ( $group->is_member ) {

    // Stop sole admins from abandoning their group
    $group_admins = groups_get_group_admins( $group->id );
    if ( 1 == count( $group_admins ) && $group_admins[0]->user_id == bp_loggedin_user_id() )
    return false;

    $button = array(
    ‘id’ => ‘leave_group’,
    ‘component’ => ‘groups’,
    ‘must_be_logged_in’ => true,
    ‘block_self’ => false,
    ‘wrapper_class’ => ‘group-button ‘ . $group->status,
    ‘wrapper_id’ => ‘groupbutton-’ . $group->id,
    ‘link_href’ => wp_nonce_url( bp_get_group_permalink( $group ) . ‘leave-group’, ‘groups_leave_group’ ),
    ‘link_text’ => __( ‘Leave Group’, ‘buddypress’ ),
    ‘link_title’ => __( ‘Leave Group’, ‘buddypress’ ),
    ‘link_class’ => ‘group-button leave-group’,

    I see here this is basically showing the Leave Group button, I got it to the point where I could hide the Leave Group button on the actual Group page, but it’s hiding it for all of them – Basically I need it for a specific group.

    Thanks for any help in advance.

You must be logged in to reply to this topic.