Change group of a newly created User in PyroCMS

妖精的绣舞 提交于 2019-12-08 09:54:29

问题


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 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.




回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!