- Write user plugin which will have the below file structure
- Write plugin manifest code here you can refere below link for the same. https://docs.joomla.org/J3.x:Creating_a_Plugin_for_Joomla
plg_add_group.php : Write below php code in this file.
defined('_JEXEC') or die('Unauthorized Access');
class PlgUserTest extends JPlugin
public function onUserAfterSave($data, $isNew, $result, $error)
//Note - This code in your case need little bit modification as here I not removed current user group which is register in your case, So if you wanted to add only student group you should be removing all other groups before adding student group.
// 3 Should be your student user group id
Joomla gives user type of plugin which have onUserBeforeSave() trigger, but this trigger never sends updated/injected data to save method of user hence we need to use onUserAfterSave() trigger to update group of user after it saves, If you see the code we have called addGroup method of joomla user helper to add group if User choose Yes in registration form 'Do you want to become Student field'.
This line is for getting your Yes/No field value, so the key need to update according to your fields name.