Forum Discussion

Quelyn's avatar
Quelyn
Genius
10 years ago

Question on "user_has_role"

Quick question.  When using the following:    <#if user_has_role == "customersupport" > Is there a away to list more than one role at a time here?  If so, what's the syntax?    Thanks!
  • rwm's avatar
    rwm
    10 years ago

    You can do the following to combine and/or logic:

     

     <#if user_has_roll?? && (user_has_role == "registered") || (user_has_role == "customer") >

     

     

  • PaoloT's avatar
    PaoloT
    10 years ago

    Hi Quelyn

     

    you have an error in the expression. The first two conditions are put in AND (&&) and there is a typo in the first one  (user_has_roll), which means the first one will always fail.

     

    You actually need to write it like this for it to work (note the corrected typo and the wrapping parentheses) because the && (AND) always takes precedence onto || (OR) 

     

    <#if user_has_role?? && (user_has_role == "admin" || user_has_role == "partner" || user_has_role == "employee" || user_has_role =="customer") >

    Which means "if the variable user_has_role exists AND has one of the values in the brackets ..."

     

    Try this and let us know,