Joomla 1.6 - Register User to correct user group with jform

310 Views Asked by At

I'm using two registration forms for the site - one that automatically registers users as "Customers" and then the second form will be for "Providers".

The global configuration for the default form is registered for the "Customer" usergroup. The second form; however, automatically registers the user as "Customer" and I would like for them to be registered as a Provider "group value = 11". Could anyone help me with this issue?

I thought that all I needed to do was create a hidden input field near the bottom like so:

<input id="jform_group" type="hidden" name="jform[group]" value="11" />

Unfortunately, this still registers the user as Customer (id value of "10").

I also tried to remove the global config to just "Registered", but instead of Registering by default to "Customer", it'll just register to "Registered". I'd like to figure out how to override this so the forms register under their correct user groups.

Any help is much appreciated!! Thank you!

1

There are 1 best solutions below

2
Minh Nguyen On

You can not do that with only adding hidden field in form. Because Joomla core doesn't process that value. It gets the default group from configuration. If not set, it's 2 for default.

$system = $params->get('new_usertype', 2);

You have to build an user plugin which can handle that hidden field and set the user's group depend on the hidden field value. The plugin should run with onContentPrepareData event and modify the data param.

You can also build an custom component which handles the user registration. DO NOT HACK TO JOOMLA CORE.