Get a group field created with Profile Manager

Hi all!

I'm developing a plugin that modifies the registration form, by allowing the new users to directly subscribe to some groups, previously tagged with a Group Profile Fields, created with Jeroen Dalsem's Profile Manager plugin.

For instance: I've created a Group Profile Field called "AllowDirectRegistration", with yes or no as values, only admin-visible. Now I want to get the list of groups marked as "yes", to fill a dropdown. Up to now, I've been using this code to get the list of all available groups:

$groups = elgg_get_entities(array(
'type' => 'group',
'limit' => 0,
'joins' => array("JOIN " . $dbprefix . "groups_entity g on e.guid = g.guid"),
'order_by' => "g.name ASC",
));

but now I need to show only those marked as "AllowDirectRegistration" with the value "yes".

I've tried to read the Profile Manager code to understand how this field is stored in the database, but as a beginner in elgg, I'm half blind on this...

Thanks in advance!

 

Nalonso

  • Answering my own question:

    Just leave the query like it is, and check for the metatag "AllowDirectRegistration" before including the options in the dropdown box, like:

    foreach($groups as $group){

        if ($group->AllowDirectRegistration == 'yes') {
                  $options_values[$group->guid] = $group->name;
        }
    }

    Best regards,

    nalonso

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