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?

  • This should do the job extensions.joomla.org/extensions/access-a-security/site-access/… I have used it and works – jonboy Jun 18 '14 at 8:16
  • Nope, it didn't work! – saibbyweb Jun 19 '14 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 Nov 12 '14 at 22:46
6

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");
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.

  • 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 Jun 18 '14 at 17:11
1

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.

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.

  • 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 Jun 19 '14 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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