We were working on a very weird problem on a Joomla website this afternoon. The owner of the website told us that he wanted his website to be “offline”, so he went to Joomla’s configuration settings and set the “Site Offline” flag to “Yes”. He told us that even though he did that, his website was still working (it wasn’t showing the offline page). The first thing that we told him to do is to logout (as admin) and see if the problem persists (Joomla is intelligent enough to allow logged in administrators to view the website even if it’s offline) – he did that and the problem was still there.
We then checked the website ourselves, and made sure that the settings were being saved properly in the configuration.php file. They were! So how come the website still shows up? We investigated further and our investigation led us to a file called application.php located under the includes folder, specifically the render method on the JSite class in that file, where there is a check if the offline flag is on or off. If the website is set to be offline, then this function call$this->getCfg(‘offline’) should return a value equivalent to true. We did some tests and the function was indeed returning true. What are we missing?
We then checked the part that actually displays the “Website Offline” message, and it was encapsulated in this condition:
if ($this->getCfg('offline') && !$user->authorise('core.login.offline')) {
If $this->getCfg(‘offline’) was returning true, this means that the other part of the function was returning false, which means that !$user->authorise(‘core.login.offline’) was returning false, which means that $user->authorise(‘core.login.offline’) was returning true. So the key was to check the authorize method on the $user object.
After a lot of investigation, we concluded that the permissions for the user groups on that Joomla site were wrong – we fixed them. This is because the function authorize above should return false, while it’s returning true.
If you’re having hard time fixing the permissions (they can be very tricky), then a quick fix to the problem is changing the above line to the following:
if ($this->getCfg('offline')) {
Doing so, however, will make the website appear offline for you even if you are a Super User – a better way for the quick fix would be changing the above line to the below:
if ($this->getCfg('offline') && ($user->name != "Super User")) {
Please note that the application.php is a core Joomla file – so any change there will affect your whole website – and may make it inoperable. Be very careful when working with this file – if you have any doubts – then don’t touch it and contact some Joomla Experts to do the work for you.
If you still can’t turn off your Joomla website then your problem lies elsewhere or it might be that you’re having problems adding the above code to your application.php file. In any case, then feel free to contact us, we are always happy to serve and our rates are very, very affordable! (…and we are very friendly!)
Hello there,
well done, I could have looked for it for ages. Thanks. However, one more question, with what line do I have to replace the line in question to allow “Super Users” and “Administrators” to log in?
Thank you.
This article is probably too old to be answered, but I am having this issue with Joomla 3.4.1 after restoring my site from a backup made with Akeeba. It warned my host was running an older version of php, though both are version 5.x. Could this be the issue?
@Anonymous:
Technically – it shouldn’t. This issue might be caused by an aggressive caching method on the server, where the server has cached the old homepage and is refusing to refresh its cache until it (the cache) has expired.
Hi all,
I had the same issue with my site not able to go offline. In working with the user group menu it seems I had deleted the public menu… All you do is add that back and it should work if you in fact are missing that menu item.
Thanks!