Above anonymouse and authenticated, I have the following roles on my site, in order: full member, senior member, moderator. I have a "Getting Started" page which I want to highlight only to users who haven't signed up or those who are new members.

here is what I have:

<li><a style="

<?php if (!in_array('full member', $user->roles)) : ?> 
color:red !important;font-size:1.1em;font-weight:bold;
<?php endif; ?>

" href="/getting-started">Getting Started</a></li>

this works fine, but when I change a member's role to Senior Member, I would like to remove the Full Member role and then the code breaks down and the red bold link starts showing again. I tried to put together a conditional but the OR/AND'ing wasn't working great.

I want the conditional to say:

if full member isn't present in user->roles array NOR is senior NOR is moderator, then show this.

the code I put together went something like: "if full member isn't present in user->roles OR senior isn't OR moderator isn't, then show this"

so really it's a (negative) AND I want, not an OR.

Comments

zeta ζ’s picture

<li><a<?php
if (!array_intersect(array('full member', 'senior member', 'moderator'), $user->roles)) :
  ?> style="color:red !important;font-size:1.1em;font-weight:bold;"<?php
endif;
?> href="/getting-started">Getting Started</a></li>
Note:
An array with zero members is considered FALSE.

Also you might want to look at http://en.wikipedia.org/wiki/De_Morgan%27s_laws if you want some bed-time reading :-)
___________________
It’s in the detaιls…

demonstration portfolio

esllou’s picture

hmm, that doesn't show to anyone at all.

zeta ζ’s picture

I’m assuming you have global $user; at the start — you must have, as your example worked before.

Don’t know what you have different
___________________
It’s in the detaιls…

demonstration portfolio

hollybeary’s picture

hmmmmm, could you possibly use a body class that reflects the user's role?