2 Day Special: Get 35% off templates, extensions, and training with the code: 2DAY35  Sale ends in
Joomlashack

How to Simplify the Joomla Registration Form

How to Simplify Default Registration Form in Joomla 3

This week, a Joomlashack University member asked us about simplifying the Joomla signup process.

Yes, in Joomla 3.7 you will be able to add fields. However, this member wanted to remove fields, without touching Joomla core files.

He wanted to remove the Name field and keep just three fields: "Username", "Password" and "Email address".

We will do this with a neat technique thanks to Lodder from JoomJunk.co.uk.

To be able to follow this tutorial, you need Joomla 3 installed. We're going to be using the Protostar template for this demonstration.

Step #1. Enable User Registration

First, let's make sure that users can register on our site:

  • In your Joomla backend, go to “Users” > “Manage” > “Options”.
  • Set the “Allow User Registration” parameter to “Yes”.
  • Set the “New User Account Activation” parameter to “Self”.

Enable Joomla registration

Step #2. Check the Default Registration Form

  • On the Joomla front end, within the login module, locate the “Create an account” link.
  • Click this link and you'll see the standard Joomla registration form you are about to override.

As you can see, this form displays six fields. In this tutorial, you will learn how to delete three of them, “Name”, “Confirm Password” and “Confirm email Address”. You are going to end up with only the “Username”, “Password” and “Email Address” fields.

Default Joomla registration form

Step #3. Creating the Override

  • In your Joomla administrator area, go to “Extensions” > “Templates” > “Templates”.
  • Click on the “Protostar Details and Files” link:

Editing Joomla template files

  • Click on the “Create Overrides” tab.
  • Find the column named “Components".
  • Click on the “com_users” folder.
  • Click on “registration”:

Creating a Joomla template override

  • You will now see a success message, saying that your override has been created:

Your Joomla override was created

Step #4. Editing the Override

  • Click on the “Editor” tab.
  • Go to “html” > “com_users” > “registration” > “default.php”:

Editing a Joomla registration file

  • Open the default.php file and look at the code. At the top, find “JHtml::_('behavior.formvalidator');”:

Code for the Joomla registration form

  • Place your mouse cursor at the end of this code, right after the double quotes mark. Hit “Enter” key a few times and copy-paste the following code snippet:

/*** Begin Registration Form Override ***/
 
$doc = JFactory::getDocument();
 $js = "
        jQuery(document).ready(function($){
             // Define the variables
            var regForm     = $('#member-registration');
            var name        = regForm.find('#jform_name');
            var password    = regForm.find('#jform_password1');
            var password2   = regForm.find('#jform_password2');
            var email       = regForm.find('#jform_email1');
            var email2      = regForm.find('#jform_email2'); 
            // Hide the required field, star, name, confirm pass and confirm email
            regForm.find('.spacer').parents('.control-group').hide();
            regForm.find('.star').hide();
            name.parents('.control-group').hide();
            password2.parents('.control-group').hide();
            email2.parents('.control-group').hide();
             // Add a default value to the name field
            name.val('Anonymous');
             // Clone password and email values to the confirm fields
            email.on('keyup', function() {
                email2.val( this.value );
            });
            password.on('keyup', function() {
                password2.val( this.value );
            });
         });    
    ";    
$doc->addScriptDeclaration($js);

/*** Finish Registration Form Override ***/

Congratulations! You just learned how to delete unwanted fields in your standard Joomla registration form using template override technique.

If you enjoyed this little trick and would like to learn more on Joomla template overrides, there are several classes on overrides inside Joomlashack University.


About the author

Born from a Ukrainian mother and Russian father, Alex migrated to the United Kingdom in 1999. Alex is a self-taught Microsoft Certified Professional. He enjoys learning modern content management systems and helping web site administrators make the most of them.

 

 

Since 2005, Joomlashack has been a leading supplier of free and commercial Joomla templates, Joomla extensions, and Joomla Training.
Joomlashack.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.