Subject: plugin_user_create_myplugin

Posted on: 08/03/12 10:53pm
By: suprsidr

I just noticed we don't have access to the groups we assign a user upon creation via SEC_inGroup
the user must be added to the groups after plugins get notified of the creation in plugin_user_create_myplugin

Any ideas of ways to react to user groups on creation?

I can monitor $_POST and get group ids, but that is a hack.

-s

Re: plugin_user_create_myplugin

Posted on: 09/03/12 02:32am
By: ::Ben

Are you looking for function SEC_getUserGroups ?

Ben

Re: plugin_user_create_myplugin

Posted on: 09/03/12 07:58am
By: suprsidr

No, I'm looking to react to a user's group assignment.

Specifically during user creation plugin_user_create_myplugin
@see the difference
PHP Formatted Code

$_POST[groups] => Array
        (
            [0] => 2
            [1] => 20
            [2] => 33
            [3] => 13
            [4] => 7
        )
SEC_getUserGroups: Array
        (
            [All Users] => 2
            [Logged-in Users] => 13
        )
 

Example:
This user was added to G2Bridge Admin group(groupId 20) and I would then need react and add them to gallery's admin group.
But SEC_inGroup and SEC_getUserGroups failes at this point - the user has not been added to the groups yet.

plugin_user_create_myplugin is called before the user is actually added to any non-default groups.

-s

Re: plugin_user_create_myplugin

Posted on: 09/03/12 10:10am
By: ::Ben

When you say
This user was added to G2Bridge Admin group


Is it manually or by G2Bridge plugin ?

Ben

Re: plugin_user_create_myplugin

Posted on: 09/03/12 10:14am
By: suprsidr

I just noticed we don't have access to the groups we assign a user upon creation

/admin/user.php -> Create New

-s

Re: plugin_user_create_myplugin

Posted on: 09/03/12 11:01am
By: suprsidr

here is my workaround:
PHP Formatted Code

function plugin_user_create_G2Bridge($uid) {
    global $_TABLES;
   
    G2B_CreateG2User($uid);

    $groupId = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'G2Bridge Admin'");
    if(in_array($groupId, $_POST['groups']) ) {
        // Add user to G2 Admin group
    }
}
 

Which works, I'm just saying we should be able to use the built-in methods.
Which would mean changing the order in which things are executed during user creation.

plugin_user_changed_myplugin works as expected and we have access to the correct groups via the built-in methods.

-s

Re: plugin_user_create_myplugin

Posted on: 09/03/12 11:08am
By: ::Ben

You can check if the user is in gallery's admin group when you check if he is in G2Bridge Admin group in your scripts. And if he is not, add him.

Ben

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=94005