1

I want content managers to see an edit button on the frontend of my websites.

When I use this on the frontend:

JFactory::getUser();

I get a guest user, also if I'm logged in into the backend.

Is there a way to check if a user is logged into the backend when visiting the frontend?

  • Little confused here. You mention content managaers, then guests, then checking users that are logged into the backend....which one are you trying to achieve? – Lodder Jan 22 '15 at 9:59
  • I want to see if the user who is visiting my website is a content manager who logged into the backend already (so has a session). – Klaasvaak Jan 22 '15 at 10:03
  • Scenario: content manager logs into backend. Visits the frontend. Sees edit button. – Klaasvaak Jan 22 '15 at 10:03
1

Joomla front-end (index.php) and back-end (administrator\index.php) is built as two separate applications, so for security reasons you have separate user sessions and user states. As you noticed, logging in to your back-end does not log you in to the front-end.

There is an extension available at JED called Wow Login that seems to be able to do what you're asking for. I haven't tried it, but according to user feedback it works as expected.

I understand that you want to save your content managers the hassle of logging in twice, but unless it's really important, I would leave it as it is. You can make a small login link in your footer if you don't want to have a login-form at the front-end.

Login tip: I have added a bookmarklet in my browser bar (Chrome) with the following code:

javascript:void((function(){var loc = location.href; loc.indexOf("?") == -1 ? (location.href = loc+"?option=com_users&view=login") : (location.href = loc+"&option=com_users&view=login");})());

It will show you a login form for ANY Joomla website by adding ?option=com_users&view=login or &option=com_users&view=login to your current URL. It's a quick way to log in to any Joomla site you manage.

  • The thing is. The content managers use the administrator, which is fine and they know how to use it. But I want to let them go to the administrator when they click on the edit button in the frontend. Right now they have to go to the backend and search for the article. – Klaasvaak Jan 22 '15 at 15:03
  • That's not how the article edit button is designed. If your managers clicks the edit button on the front end, the front-end editor will open, with mostly the same options as the back-end editor. I'm a little confused as to what you're trying to achieve, your question and your comments ask for different things. – johanpw Jan 22 '15 at 15:12
  • I forgot to mention. I use my own components and templates. There is no login functionality on the frontend. I want to add the edit button in my own templates where I can route it to the backend. But I only want to show that button to people who are logged into the backend. – Klaasvaak Jan 22 '15 at 15:25
1

@klaasvaak, I don't know if you need this anymore, but just in case somebody does:

Joomla is designed to identify the user sessions per application viz site and administrator with a session_name which defaults to the name of the JApplicationCms instance if not set otherwise.

Fortunately, it has given you a way to assign a fixed name to all the user sessions in Joomla configuration.php file. Once you do this, all sessions have the same identity and hence session content will be shared automatically.

Just add following line in the configuration.php file in your site root and you are good to go:

public $session_name = 'izharaazmi.com';

WARNING: All of the users will be made to login into everywhere (I mean including backend) unless you disallow backend login for those user groups in Global Configurations > Permissions. However this is the default setting in Joomla, hence you may not need to bother. But always make sure of it.

Last advice: Don't be a lazy, at least when its a matter of security :-)

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.