How to disable front-end login in Joomla

The login feature on Joomla is default and you cannot disable it normally. If done wrong, it can cause errors and you won't be able to log into the admin area - which is terrible.

However, for security reasons, not all websites want to integrate this login feature. They want to turn it off to restrict the risks.

There are some simple ways like turning off the login module or editing the file (deleting the controller.php file)... however, these are not optimal. Why?

  • If the module is disabled, users can still login to your website using the link https://example.com/index.php?option=com_users&view=login
  • If you edit the core file, you cannot update Joomla to the new version.

In this article, I will show you how to disable the login feature and still meet the above requirements.

This article uses PHP language, so you need a module that supports it. You can use the module Flexi Custom Code (I will use it in this article), download it here. Let's get started!

----------------------

First, download and install the Flexi Custom Code module.

Next, go to the Admin section > Manage modules > New > Flexi Custom Code.

Select flexi custom code module

At the module's settings page, set the value for USING PHP CODE? is Yes.

Enable PHP on joomla

In the Insert Code field, enter:

-- With J2.5 and J3:

<?php
$app = JFactory::getApplication();
$option = $app->input->getCmd('option');

if($option=='com_users')
{
	// J2.5
	// JError::raiseError(404, 'Page Not Found');

	// J3
	throw new Exception('Page Not Found.', 404);
}

-- With J4:

<?php
use Joomla\CMS\Factory;

$app = Factory::getApplication();
$option = $app->input->getCmd('option');

if($option=='com_users')
	throw new Exception('Page Not Found.', 404);

Then you choose where to display the module to display it on the entire site (Module Assignment: On all pages).

Display module in whose website

Done! This feature will no longer be available on your site.

You may also like

How to upload and attach files to Joomla articles

K2 to Content Migration

How to add Google Reviews to Joomla website

Say something here...
You are a guest ( Sign Up ? )
or post as a guest
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.


Powered By JLex Comment.