简体   繁体   中英

Joomla: If user has access level X, then

I want to show some content only if a user belongs to the access level with the IDs 4 and 5. It should start with something like that:

$user = JFactory::getUser();

and then I need to check the access level of the logged in user. Help would be very much appreciated!

You could use the following code:

<?php
    $user = JFactory::getUser();
    $levels = $user->getAuthorisedViewLevels();

    if(in_array(4, $levels) && in_array(5, $levels)) :
?>

        Content

<?php endif; ?>

Reference: JUser::getAuthorisedViewLevels - getAuthorisedViewLevels

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM