215 Posts
cubist
10 years ago
1
Topic

Thought I'd share this code that detects what group id the user is a part of.

Really useful for adding Login and Log Out menu items, but hiding the latter when logged in.

Add this to your template index.php page:

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

if (is_array($groups)) {
foreach($groups as $group) {
//echo "

Your group ID is:" . $group . "

";
} }

then before tag, add some CSS inside PHP tags to hide the item id of the menu for Login:

if ($group >= 2) echo "li.item206 { display: none !important; }";

Get a VIP membership
572 Posts
_jrmo
10 years ago
0
Level 1

Thanks for the share cubist, very useful indeed.

Get a Book for SEBLOD