I am developing a website in Joomla 3.0. What I am trying to do is to create a custom login form. The reason I want to do that is to enable users to select the user group they want to be put in while they are registering. So I need to create a dropdown box in the login form. From this dropdown box users would be able to pick up the desired user group. So far I've tried using various plugins and extentions but the problem is that they can't be customized the way I want. So please, if you have any idea how to achieve the result I am looking for share it with me. I guess I will have to try to code it myself, but even in this case I would need a lot of help. Giving me tips and citing good tutorials would also be helpful.
Thank you
PS: If you have solution to my problem for another version of Joomla please share it with me.
Probably UsergroupSelector plugin can help you to achieve this. This plugin adds a field in registration form. In case if you do not want to use default html, then you need to add a select box html in your overrided template.
The best solution for adding a custom field during the user registration process is probably using a plugin.
You can use a commercial plugin that is available called Multi-Profiles Registration (demo here), that appears to be doing exactly what you want (I have never tested it).
This will cost you some money and save you some time, but I will layout the alternative way, which is developing your own plugin.
Lucky for you, there is an excellent tutorial here, which is actually a chapter form a book called Joomla! Programming (especially page 5 of the tutorial).
Writing a plugin takes time and I will not go over all of the details.
The main steps include:
- Create a plugin configuration file, that will include a list of groups to select from (form element). This is where you (or anyone using the plugin) will select the groups available for registration (groups can be fetched via
UsersHelper::getGroups()
).
- Augment the registration form with a select box that includes the desired user groups from the plugin config. This can be done by creating a layout override for your template (
templates/<your template>/html/com_users/registration/approval.php
) or by injecting it into the document at some phase of the render event by the plugin, which is probably the preferred method if this plugin should be portable.
- Set the desired group by the plugin by processing the form data and overriding the
groups
data parameter on the onUserBeforeSave
event.