Users are assigned the role of Candidate on registration. Then when purchasing certification they are also assigned the role of ApprovedCandidate.
I have a block I want to display IF they are a Candidate but not if the are also an ApprovedCandidate. (there is also another condition it needs to meet, but that part is working fine)
I have tried all the conditional options I could, but nothing seems to give me the results I want.
Hello,
The "Current user role" option is using shortcode [wpv-current-user info="role"] as the condition, but it can only retrieve the main role(Candidate) of current user role.
But in your website one same user can have multiple roles(Candidate and ApprovedCandidate), in this case, you can try with a custom permission, see below sandbox website:
Login URL: hidden link
1) Dashboard-> Toolset-> Access Control-> Custom Roles,
hidden link
Find role "Candidate", and click link "Change permissions", add a custom permission "candidate_capability"
Find role "ApprovedCandidate", and click link "Change permissions", add a custom permission "approvedcandidate_capability"
see my screenshot change-permission.jpg
2) Dashboard-> Toolset-> Settings-> Front-end Content
hidden link
in section "Functions inside conditional evaluations", add WordPress built-in function name: current_user_can
3) Setup the condition as below:
hidden link
( ( current_user_can(approvedcandidate_capability) ne '1' ) AND ( current_user_can(candidate_capability) eq '1' ) )
And test again.
It works fine in above sandbox website.
More helps:
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/
https://developer.wordpress.org/reference/functions/current_user_can/