Joomla – Redirection after user registration

In Joomla, after successful registration, users by default are redirected to a login page (if account doesn’t need to be activated). From there (after logging in) users are redirected to a user profile page. This happens even if you have Login Redirection set to something else in Login Form Module.

To change this behaviour you can redirect users after registration to any other page on your website.
To do this you need to edit a core Joomla file. Be aware that your changes may be overwritten by a Joomla update. Always document changes you make to core Joomla files so you can quickly re-do them if required.

Open file:
components/com_users/controllers/registration.php

Scroll down to the very bottom. Starting line 162 or so you will have flowing code:


// Redirect to the profile screen.
 if ($return === 'adminactivate'){
   $this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_VERIFY'));
   $this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
}else if ($return === 'useractivate') {
   $this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE'));
   $this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
} else {
   $this->setMessage(JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS'));
   $this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false));
}

 

 

In this section you have 3 links starting index.php?

  • First one (index.php?option=com_users&view=registration&layout=complete) is executed after user registration if account has to be activated by an administrator
  • Second (index.php?option=com_users&view=registration&layout=complete), if account has to be activated by user
  • Third (index.php?option=com_users&view=login), if account activation is not required.

Replace links depending on type of registration you use with FULL URL of your redirection page and you are done.
For example, if user activation on my website is not required and I want to redirect users after registration to http://www.mywebsite.com/welcome-reg the updated code will be:


// Redirect to the profile screen.
if ($return === 'adminactivate'){
   $this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_VERIFY'));
   $this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
} else if ($return === 'useractivate') {
   $this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE'));
   $this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
} else {
   $this->setMessage(JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS'));
   $this->setRedirect(JRoute::_('http://www.mywebsite.com/welcome-reg', false));
}

Regardless to which page on your website you redirect, system message “Thank you for registering…” will be still displayed. If you don’t want this message, remove full line above your redirection URL. e.g.  $this->setMessage(JText::_(‘COM_USERS_REGISTRATION_SAVE_SUCCESS’));

If you don’t require account activation (New User Account Activation set to None) this is all you need to avoid User Profile page. However, if user has to activate account via email (Account Activation set to Self) this may not be enough. Immediately after registration user will be redirected to a web page you provided in the code as expected. However, when user clicks on a link in the activation email, they will be taken to the previously mentioned login form and if they use it to login, they will get to the User Profile page. To prevent this you can disable User Profile page completely and instead redirect users to any page you like. Read this article to find out how.

Joomla 1.6
Joomla 1.7
Joomla 2.5


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *