only the admin to create group?

I want only the admin to create groups, how do I acheive this?

  • You would probably need to get in there and hack around in the groups code to achieve this. You'd need to find wherever there is a link to create new groups and wrap it with a conditional: 

    if (isadminloggedin()) {

    ... new group link code ...

    }

    You'd need to make sure the groups edit action prevents regular users from creating groups, just in case. For that go into groups/actions/edit.php and add: admin_gatekeeper(); Do the same in start.php for the groups page handler, ie: 

    case "new":

    admin_gatekeeper();

     

  • Thanks,but I do not know much about coding. I will appreciate if you can show me where I should insert the codes you have just posted, if there is any existing code that I should also delete

  • @jekwumoore Before asking questions do a search in the community and using google...

    coz most of what you are asking (have seen some other posts of you also) have been answered many times in the community... so do you maths first

     

    HaPPy ElGGinG :)

    Do GooD :)

  • i have tried some searches but none gave me what i wanted, if you know the links of a similar topic then kindly post it here

  • Google "elgg only admin create group" ;)

  • i have found some,i will try it out on my demo site before implementing on my main site, thanks

  • so far I have restricted group creation by changing

      gatekeeper(); 

    to

    admin_gatekeeper ();

    done in mod/groups/new.php  and mod/groups/edit.php

     

    One more thing, the "create group" menu still shows though non-admins can still not create group.

     

    How do I make this invisible to users and only visible to admins?

  • I just played around with the code and this is what your mod/groups/start.php should look like after adding if (isadminloggedin()). Doing so will hide the create class menu for the rest, and only the admin can view.

    // Add submenu options

    if (get_context() == 'groups' && !($page_owner instanceof ElggGroup)) {

    if (isloggedin()) {

    add_submenu_item(elgg_echo('groups:owned'), $CONFIG->wwwroot . "pg/groups/owned/" . $_SESSION['user']->username, '1groupslinks');

    add_submenu_item(elgg_echo('groups:yours'), $CONFIG->wwwroot . "pg/groups/member/" . $_SESSION['user']->username, '1groupslinks');

    add_submenu_item(elgg_echo('groups:invitations'), $CONFIG->wwwroot . "pg/groups/invitations/" . $_SESSION['user']->username, '1groupslinks');

    }

    if(isadminloggedin()){

    add_submenu_item(elgg_echo('groups:new'), $CONFIG->wwwroot."pg/groups/new/", '1groupslinks');

    }

    add_submenu_item(elgg_echo('groups:all'), $CONFIG->wwwroot . "pg/groups/world/", '1groupslinks');

    }

     

    }