New topic Closed topic
avatar image
1
Check if current_user has a specific role in an expression
By Created , last editted

Hi, I'm trying to set a visibility-condition on a component in a form. I can't use a filter because I've got multiple objects to check on. 

I tried to use the include() function; 

include?([var:current_user.roles], var:role)

where var:role is a global variable object of role defining the role I need, but this doesn't work. I've also tried 

include?([var:current_user.roles.id], var:role) 

where var:role was used as a number, equal to the needed role's id.

Examples above use [ ],  without these it doesn't work either.​

var:current_user.roles.name == "name" 
 

doesn't work either, obviously...

Does anyone know how to do this?


Hi, I'm trying to set a visibility-condition on a component in a form. I can't use a filter because I've got multiple objects to check on. 

I tried to use the include() function; 

include?([var:current_user.roles], var:role)

where var:role is a global variable object of role defining the role I need, but this doesn't work. I've also tried 

include?([var:current_user.roles.id], var:role) 

where var:role was used as a number, equal to the needed role's id.

Examples above use [ ],  without these it doesn't work either.​

var:current_user.roles.name == "name" 
 

doesn't work either, obviously...

Does anyone know how to do this?

Answers
Sort by:

This topic is closed.