Only Group Owners to edit group and not Site admin

Please i want only owners of groups to edit their group. I don't want site admins to have access to edit groups. Please how can do this. I tried his but i didn't work. Any help pls

    if(($group = get_entity($group_guid)) && ($group instanceof ElggGroup) && ($group->owner_guid)){

  • I'm not sure if it site admins can be denied access to anything, but if they can it would be by using the permissions_check plugin hook

    <?php

    elgg_register_event_handler('init', 'system', 'myplugin_init');

    function myplugin_init() {

      elgg_register_plugin_hook_handler('permissions_check', 'group', 'myplugin_group_perms', 1000);

    }

    function myplugin_group_perms($hook, $type, $return, $params) {

    if (elgg_is_admin_logged_in() && elgg_get_logged_in_user_guid() != $params['entity']->owner_guid) {

      return false;

    }

    }

  • Thanks i will try to see if it works.

    Thanks once again

  • Thanks i will try to see if it works.

    Thanks once again

  • Hello i changed the code to 1.7 but it didn't work maybe the code isn't right. Please help check

    • <?php
    • function myplugin_init() {
    •   register_plugin_hook('permissions_check', 'group', 'myplugin_group_perms', 1000);
    • }
    • function myplugin_group_perms($hook_name, $entity_type, $return_value, $parameters) {
    • if (isadminloggedin() && get_loggedin_userid() != $params['entity']->owner_guid) {
    •   return false;
    • }
    • }
    • // Initialise plugin
    • register_elgg_event_handler('init', 'system', 'myplugin_init');
    • ?>
  • @ Matt it is Solved. I added the below code before $group->canEdit())){

    ($group->isMember($user)

    like this

        if(($group = get_entity($group_guid)) && ($group instanceof ElggGroup) && ($group->isMember($user) && $group->canEdit())){

  • Please how can i allow only non-admins to request memebership in a closed group?