Select your language

Core Expert

Stuck on a Complex Joomla Issue?

Don't waste billable hours debugging extension conflicts, layout breaks, or migration glitches. Get core contributor help within 24 hours.


GDPR Compliant Coding
US/EU Timezone Crossover
White-Label Support for Agencies

Problem: We have a public menu, and restrict it for non logged in users, if we use joomla menu access level restriction, and set access to registered, it will hide menu for public, so we have to write code to achieve our requirements.

Solution:

Consider following code and insert into HTMLView file.

// Import required classes
use Joomla\CMS\Factory; use Joomla\CMS\Router\Route; use Joomla\CMS\Uri\Uri; // Define redirect after login $returnUrl = base64_encode('https://b2c.com.pk/list-business'); $loginUrl = Route::_('index.php?option=com_users&view=login&return=' . $returnUrl, false); // Redirect non-logged-in users to login page $user = Factory::getUser(); if ($user->guest) { Factory::getApplication()->redirect($loginUrl); exit; }

Still need help! no problem, feel free to contact us Today


 Abdul Waheed : (Hire Joomla & PHP Pakistani Freelancer)

Our Trusted Partners

We collaborate with reliable organizations and technology partners to deliver high-quality digital solutions.

Partner 1