Elgg 1.9rc3 Manage only one group

Hello !

I would like to know if it's possible to manage only one group. In Elgg we can manage several groups but is there a solution in the code to disable the ability to own more than one group ?

Thanks for your support.

  • Using a plugin hook you can hook into the group creation action. Then check for any existing groups owned by the current user and prevent the action from happening if he owns a group. 

    Also, you need to register an event handler for the pagesetup event and remove the create group button, if the user owns any group.

    For both these you need to have some ideas on plugin hooks and event handlers in elgg. You can start at http://learn.elgg.org/

  • Thank you for your reply.

    It's what I thought. It won't be easy to do it ...

  • I found an issue. I have modified /mod/group/start.php next to "case 'add':"

    My code :

                    case 'add':
                    $guidteam=elgg_get_logged_in_user_guid(); //To stock user ID
                    $sql = 'SELECT * FROM elgg_entities WHERE owner_guid='.$guidteam.' AND type="group"'; //To search if this user ID own a group
                    $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); //To execute the request
                    if($data = mysql_fetch_assoc($req)) //If the user own a group
                        echo 'Vous ne pouvez pas creer plusieurs Teams'; //tell him he can't have more
                    else {
                        groups_handle_edit_page('add'); //Else the user doesn't own a group, he can create a group

    It's simple but It's work, I am not a good developer.

  • You shouldn't modify that plugin directly, you can do all of the changes in your own custom plugin that won't be affected by upgrades.


    Additionally you should look at the groups plugin for the correct way to get groups that user owns, there are quite a few places this is done in the plugin using elgg_get_entities

    Direct sql querying is not recommended as it breaks out of the Elgg API and bypasses things like access

  • You're right. I'm going to find a way which respect what you say.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking