Skip to:
Content
Pages
Categories
Search
Top
Bottom

Restricting Group Deletion to Super Admin


  • kwahlquist
    Participant

    @kwahlquist

    I am using buddypress as a closed and private social intranet. I allow users to create their own groups for planning, however, I have a core infrastructure of groups that are created by the super admin to reflect the organizational structure of our non profit. I need to allow members to admin these groups, but I do not want members (even group admin of these groups) to be able to delete a group that was initially created by the super admin.

    I am imagining I need to add some logic that queries the group > admin.php file around the

    if ( bp_is_group_admin_screen( ‘delete-group’ ) )

    functionality but do not know exactly what I am doing beyond that. Any help would be appreciated that can assist me in restricting group deletion to only user 1 for all groups created by user 1 (super admin).

    Let me know if I can clarify anything further. I will turn on email notification and jump on pretty quick to follow up.

    Thanks in advance to anyone who can lend a hand!

Viewing 4 replies - 1 through 4 (of 4 total)

  • danbp
    Moderator

    @danbp

    Hi,

    simply remove the delete group button from group admin. Give this a try, only site admin will see the button. Add snippet to bp-custom.php

    function kwahlquist_remove_group_admin_tab() {
    global $bp;
    	if ( ! bp_is_group() || ! ( bp_is_current_action( 'admin' ) && bp_action_variable( 0 ) ) || is_super_admin() ) {
    		return;
    	}
    	// Add the admin subnav slug you want to hide in the following array
    	// other admin subnav items are: group-settings, group-avatar, group-invites, manage-members
    	$hide_tabs = array(    		
    		'delete-group' => 1
    	);
            // since BP 2.2
    	$slug = bp_get_current_group_slug() . '_manage'; 
    	
    	// Remove the nav item
    	foreach ( array_keys( $hide_tabs ) as $tab ) {
    		bp_core_remove_subnav_item( $slug, $tab );
    	}
    }
    add_action( 'bp_groups_setup_nav', 'kwahlquist_remove_group_admin_tab', 9 );

    kwahlquist
    Participant

    @kwahlquist

    Hay Danbp, Thanks for the response!

    I think this is on the right track, however, I still need to keep the delete button for all admins of for all groups that the super admin did not create.

    So if the group was created by super admin, only super admin will see the delete group function.

    If the group was created by any other user, that groups admin will see the delete group function.

    Thanks again for trying to help, and let me know if you you have advice for getting this level of functionality.


    danbp
    Moderator

    @danbp

    Check for group_creator.

    bp_is_group_creator


    kwahlquist
    Participant

    @kwahlquist

    Thanks Dan! I will look into it and let you know what I come up with.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Restricting Group Deletion to Super Admin’ is closed to new replies.
Skip to toolbar