How to find out if Joomla user in Admin or frontend folder

This snippet will demonstrate how to determine if a user is currently viewing the administrator folder or frontend. It’s a little more complicated that WordPress but within a few lines; it’s possible.

$app =	JFactory::getApplication();
$client = $app->getClientId();
	if($client == 0)
	{
		echo "You are on the frontpage";
	}else{
		echo "You are on the admin side";
	}

The snippet above basically gets the Joomla Application class, then second line calls the getClientId function returns 0 if the user is in the front-end of the site or 1 if the user within the admin.

B4uCode

I am a passionate PHP user with a love for Open Source systems. With a few years of programming these technologies, I am fortunate to be able to share my thoughts. Joomla and WordPress are my favorite systems to develop. That's enough for now.

You may also like...

Leave a Reply

Your email address will not be published.