Attention

TYPO3 v10 has reached end-of-life as of April 30th 2023 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.

Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v10 here: TYPO3 ELTS.

be.security.ifHasRole

This ViewHelper implements an ifHasRole/else condition for backend users and backend groups.

Role refers to backend user groups. The role attribute can either be the title of a group, or the uid.

Examples

Basic usage:

<f:be.security.ifHasRole role="Administrator">
   This is being shown in case the current BE user belongs to a BE usergroup (aka role) titled "Administrator" (case sensitive)
</f:be.security.ifHasRole>

Everything inside the <f:ifHasRole> tag is being displayed if the logged in backend user belongs to the specified backend group.

Using the usergroup uid as role identifier:

<f:be.security.ifHasRole role="1">
   This is being shown in case the current BE user belongs to a BE usergroup (aka role) with the uid "1"
</f:be.security.ifHasRole>

Everything inside the <f:ifHasRole> tag is being displayed if the logged in backend user belongs to the specified backend group.

IfRole / then / else:

<f:be.security.ifHasRole role="Administrator">
   <f:then>
      This is being shown in case you have the role.
   </f:then>
   <f:else>
      This is being displayed in case you do not have the role.
   </f:else>
</f:be.security.ifHasRole>

Everything inside the <f:then></f:then> tag is displayed if the logged in backend user belongs to the specified backend group. Otherwise, everything inside the <f:else></f:else> tag is displayed.

Arguments

then

DataType

mixed

Required

false

Description

Value to be returned if the condition if met.

else

DataType

mixed

Required

false

Description

Value to be returned if the condition if not met.

role

DataType

string

Required

false

Description

The usergroup (either the usergroup uid or its title).