3

Suppose a menu's (or article's) access is set to registered users only.

Path to the page : http://localhost/menu

when this URL is directly access by any GUEST USER, he's redirected to :

http://localhost/...?view=login which asks him to login first.

How to change the path to redirect page..i have made a custom login page, i want it to be redirected to my custom made login page and not to http://localhost/...?view=login. Which file needs to be edited to acheive that?

3
  • This should do the job extensions.joomla.org/extensions/access-a-security/site-access/… I have used it and works
    – jonboy
    Commented Jun 18, 2014 at 8:16
  • Nope, it didn't work!
    – saibbyweb
    Commented Jun 19, 2014 at 6:46
  • I looked everywhere for a solution to this issue. I have a custom login menu/page and wanted anyone (guest, etc) directed there. This variable view=login was redirecting users to some template and I tried everything, even hacking it together. This solution above by @Saibbyweb is so simple and does the trick. (If necessary, simply copy the PHP files to the folder YOUR_TEMPLATE/html/com_users/login) then modify as stated above....it worked like a charm!! Thank you!!
    – user2190
    Commented Nov 12, 2014 at 22:46

5 Answers 5

5

I figured it out myself! :)

You need to edit this file : /templates/your_template/html/com_users/login/default.php or if your template folder doesn't consist of html folder, edit this one: /components/com_users/views/login/tmpl/default.php

and change

if ($this->user->get('guest')):
echo $this->loadTemplate('login');

to

if ($this->user->get('guest')):
header("Location: URL_WHERE_YOU_WANT_TO_REDIRECT");
0
4

If you would like to make your login page look different, you can do a template override and no need to redirect to a different page. Find your templates folder and select the template you are using. Create an html folder if you do not have one. The component you wanna override is com_users.

If you have a look at /components/com_users/views folder, you can see all the views that can be overriden in the template folder. The one we need now is in the login folder. /components/com_users/views/login/tmpl - there are default.php default_login.php and default_logout.php.

You have already created an html folder in your template, now you need to copy these files in the following location:

/templates/yourtemplate/html/com_users/login

That will result in having 3 files:

/templates/yourtemplate/html/com_users/login/default.php
/templates/yourtemplate/html/com_users/login/default_login.php
/templates/yourtemplate/html/com_users/login/default_logout.php

You do not need the tmpl folder.

You can edit the default_login.php to do the override.

1
  • i have already customized my site alot! i just need to change the redirect path..otherwise i need to make changes in around 50-60 pages :/
    – saibbyweb
    Commented Jun 18, 2014 at 17:11
2

You need to create a plugin, which will check the url and Usergroup. If you user is guest then you can redirect user to desired url.

Below link may help you.

1

The answer by @saibbyweb resulted in an infinite redirect loop in Joomla 3.9.

I then figured out that my problem was with the component I was trying to access, com_akeebasubs, which used:

$this->container->platform->redirect(\JUri::base() .'index.php?option=com_users&view=login&return=' . $myURI);

The redirect worked properly after I changed this line to:

$this->container->platform->redirect(\JRoute::_('index.php?option=com_users&view=login&return=' . $myURI));

You do need to have a User > Login Form menu item.

1
  • Thank you for contributing. Please take the tour and perhaps tell us about yourself by editing your profile. I look foward to seeing more of your insights shared. Commented Dec 5, 2019 at 20:01
0

If you wanna change where the user is going to be redirected after login and logout, you van do this in the login module of joomla. There are 2 fileds for this.

1
  • when the user is detected as guest, he's directed to the login page http://localhost/...?view=login (which say please login first) , i want to change that URL
    – saibbyweb
    Commented Jun 19, 2014 at 6:46

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.