Search code examples
codeigniterpyrocms

Change group of a newly created User in PyroCMS


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?


Solution

  • 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 a events.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.