Hi there!

I´ve got this PHP snippet that allows me to show the tabs only to authenticated users.
How do I modify this to show only if it does belong to that role, but does NOT belong to role X?

<?php global $user; //el link aparece sólo para usuarios registrados
if (is_array($user->roles) && in_array('authenticated user', $user->roles)) {?>	
		<?php if ($tabs): ?>
          <div id="content-tabs" class=""><?php print $tabs; ?></div><!-- /#content-tabs -->
        <?php endif; ?>
<?php } ?>		

I know that maybe it should contain something like an elseif, and the negative ! sign. But how do I do that?
Thanks for your help!!

Rosamunda

Comments

nevets’s picture

I would replace

if (is_array($user->roles) && in_array('authenticated user', $user->roles)) {?>

with

// Change role_x and role_y to be the actually role ids you want to test
$role_x = 4;   // Want this role
$role_y = 6;   // but not this role
if (is_array($user->roles) && !empty($user->roles[$role_x]) && empty($user->roles[$role_y])) {?>
Rosamunda’s picture

Thank you, nevets!