How to Remove Fields from the Joomla Registration Form

How to Remove Fields from the Joomla Registration Form

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

This Joomlashack member wanted to remove fields from the signup form, 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, the Name, the Confirm Password and the Confirm email Address. You are going to end up with only the Username, the Password, and the Email Address” fields.

Default Joomla registration form


Step #3. Creating the Override

  • In your Joomla administrator area, go to Extensions > Templates > Templates
  • Click Protostar Details and Files

Editing Joomla template files

  • Click the Create Overrides tab
  • Find the column named Components
  • Click on the com_users folder
  • Click 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 of the file, find the following code:

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 the 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

Steve is the CEO of Joomlashack. Originally from the UK, he now lives in Sarasota in the USA. Steve has been involved with Joomla since 2006.