Check if a user has a particular role
Sometimes we need to control how the workflow is executing based on the currently logged-in user role. That’s easy. There is a special variable {USER}
that contains a list of currently logged in user details. So, we just need to specify a logic rule that checks {USER.roles}
for a particular WordPress role name. You can configure this rule in the logic actions like Stop if and Run another workflow. See an example of how to stop the execution of the workflow if the currently logged-in user is not an administrator. Note that we use Not contains comparison because {USER.roles}
is a list and we need to make sure it contains a string administrator.
The next example executes selected workflow conditionally if a current user has an administrator or editor role.