Hi,
Thank you for contacting us and I'd be happy to assist.
For the current user's main role-based conditions, you can add the target role's string on the right-hand side, as a static value.
For example, the attached screenshot, shows a simple condition to see if the current has the "administrator" role (as the main role) or not.
Checking for other or additional roles is tricky, because there is no built-in method available for this. To check for all (i.e. main and additional) roles attached to the current user, you can register a custom shortcode:
add_shortcode('custom_check_user_roles', 'custom_check_user_roles_func');
function custom_check_user_roles_func($atts) {
$roles = $atts['roles'];
$content = do_shortcode('[toolset_access role="'.$roles.'" operator="allow"]1[/toolset_access]');
if(!empty($content)) {
return 'yes';
}
else
{
return 'no';
}
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
Also add "custom_check_user_roles" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.
After that you'll be able to use this custom shortcode like this:
[custom_check_user_roles roles='Administrator,Editor']
The above shortcode will return 'yes' if the current user has an Administrator or Editor role (no matter as primary or additional roles) and 'no' if not.
And you'll be able to use the same custom shortcode in the conditional block too, by just specifying the role names.
( screenshot: hidden link )
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar