I have a site mostly targeted for registered users but I want to provide guests (potential new users) with registration form. This registration form is a Menu item publicly available (it consists of a component with one module). In helper class of the module I have a very simple query as I need to fetch one data from my joomla database before processing the form data:

$db = JFactory::getDbo();
$query = $db->getQuery(true);

      ->where($db->quoteName('name') . '=' . $db->quoteName('something'));
$params = $db->loadResult();

The problem is that I am getting redirected to login page on executing this part of code (I didn't have this problem before so I am sure it is connected with JFactory::getDbo or something with db connection). I guess it is because of the permissions to enable access to db only for logged-in users.

Is it possible to get around this problem without security breaches? Any help appreciated.

  • There shouldn't be any permission issues with JFactory::getDbo(). Are you sure you've set the access level for the actual module to public? Also, where is the rest of the code for the module? A redirect ony occurs if you specify one and it's not coming from your database query.
    – Lodder
    Feb 16, 2017 at 14:06
  • Certainly the code posted is not related with the redirection you get. Likely your menu item is set to registered users or generally your issue is something like that - meaning that you are trying to access a restricted page. What Lodder said though about the module been set to public wouldn't redirect you, rather it would keep your module hidden from public.
    – FFrewin
    Feb 16, 2017 at 16:26
  • I checked everything and everything, so the menu item, the component attached to it and assigned to it module are public but due to some configuration it does not allow me to access db. If this helps: I tried to make an AJAX call from my module (exactly from an HTML form defined in /tmpl/default.php file) to itself to mod_mymodule.php where the request was to be processed. As far as I was using default form submitting behavior I was redirected to login page (on the Network tab in Inspect Element option in FF I noticed a response 303- See other), so the problem is the same here, I suppose.
    – Rafichu
    Feb 17, 2017 at 10:19

2 Answers 2


Finally I managed to resolve the issue. It was my mistake when generating the query. I used $db->quoteName('something') instead of $db->quote('something') which resulted in a wrong query (I checked the generated query string on phpmyadmin and it was indeed incorrect as quoteName(...) results in surrounding the string with grave char (`) instead of single quotation marks). This small detail was causing the error and Joomla redirection to login page. Hope it will help somebody with simillar issues.


This is most likely caused by a security plugin somewhere on your website. Try uninstalling all non-core plugins one by one in order to find out which one is the culprit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.