I'm new to Joomla and php programming and I need some help to implement an idea !!
I'm developing a website with Joomla 3.6.1 and I need to customize registration form with some new fields.
So, what have I already done?
I copied the plugin "User - Profile" and I started modifying it.
So I modified profile.xml, profile.php accordingly to this guide, and everything works fine.
But, in this way, currently all new fields I added appear into the form without any condition.
Instead, I installed the "Usergroup Selector" plugin from Function 90 and what I want to reach is:
when I select Group1, only some fields must be displayed and when I select Group2 only other fields must be displayed, hiding fields related to Group1.
So I'm modifying my profileunical.php trying to add into "//Case registration" (row 174) a new condition to import usergroup selected from Usergroup Selector plugin and using this value into an IF statement to show some fields only when the condition is meet.
That's the piece of code I would like to improve (because actually do not works!):
Code: Select all
// Case registration
elseif ($name == 'com_users.registration')
{
$plugin = &JPluginHelper::getPlugin('user', 'usergroupselector');
$pluginParams = new JRegistry($plugin->params);
$params->get('usergroups','default_value');
$cgroup = $params;
// Toggle whether the field is required.
if ($this->params->get('register-require_' . $field, 1) > 0 && cgroup == "Studente")
{
$form->setFieldAttribute($field, 'required', ($this->params->get('register-require_' . $field) == 2) ? 'required' : '', 'profileunical');
}
else
{
$form->removeField($field, 'profileunical');
}
}
Can someone help me ?
Thanks !!!