I want for all users who in the group "register" to show a message, and for those who are in other groups, not to show. How to make such a check in Joomla 3? The beginning is and how further the group register id 2

$user = JFactory::getUser(); $user->groups 

    1 answer 1

     $user = JFactory::getUser(); $groups = $user->get('groups'); foreach($groups as $group) { $userGroup = $group; // ID группы пользователя } if($userGroup == 2){ echo 'привет'; } 

    or you can simply check the user for "not a guest", but then they will enter not only registered, but a super user, manager, etc.

     $user = JFactory::getUser(); if (!$user->guest) { echo 'авторизован'; } 
    • It turns out like this: $ user = & JFactory :: getUser (); $ user-> get ('2'); if ($ user == 2) {echo "Hello"; } - Anatoly
    • Sorry, that code does not work in Joomla 3, it is outdated, corrected the answer - Vadim Leshkevich