问题
Using PyroCMS 2.2, how can I have a registration form assign a user to one of the new Groups I created. Within the admin panel, I have a created a user group called client
. When my registration form within my module is sent, it creates the client, but sets the type for group to $config['default_group'] = 'user';
within the core module.
Is there a way for me to set the group to client for this specific registration form in this module?
回答1:
I suggest this:
- When you redirect the user to the costum registration form, set a session variable with value of your costume module name for example
- Use PyroCMS events (
Events::trigger('post_user_register', $id)
) and build aevents.php
file for your module so that, after every user registration this event will be triggered and since you have set the session variable, you can decide to change the user group of newly created user to an appropriate one and be sure to unset the session variable after you are done.
Hope you get the idea.
回答2:
It doesn't look like there is an inbuilt way to do this.
system/cms/modules/users/controllers/users.php:384
// We are registering with a null group_id so we just
// use the default user ID in the settings.
$id = $this->ion_auth->register($username, $password, $email, null, $profile_data);
It also appears it isn't possible to override the core modules.
Seems like you have 2 options:
Modify the core module
Try to port the user module into your own module
来源:https://stackoverflow.com/questions/16109933/change-group-of-a-newly-created-user-in-pyrocms