Hi,
I have a view which I want to make dynamic based on the current user role. I'd like to be able to show the content of the view only if the user role is 'sitter' which is a role I've created. If the role is 'client' they should not see the content.
I couldn't find a way to get the role in Twig so wrote a function in PHP to call from the Twig. The function works correctly but I can't see a way to use the result of the function in the Twig template.
Ideally I'd have something like this:
{% if ( {{mb.check_user_role()}} =1 ) %}
TWIG FOR SITTER ROLES ONLY
{% endif %}
TWIG FOR CLIENT ROLES
This approach doesn't seem to make use of any return value from the PHP function.
I'm assuming that return functions aren't supported so is there another way to do what I'm trying to achieve?
Thanks