Hi - hopefully this should be an easy one!
I have a single line of content that I want to hide using conditional logic. I want it to be visible "ONLY" to Admin and Editors "PLUS" 1 specific person. I got this far using your documentation which I think is saying: IF the current user is Bruce then show the text Bruce is logged in now).
[wpv-conditional if="( '[wpv-current-user]' eq 'bruce' )"]Bruce is logged in now [/wpv-conditional]
I would like to do the exact same thing but the condition should be the users email or if preferable their user id. Would you be able to tell me what the shortcode would look like if I am saying
IF the current user's email address is example@email.com then show this text. I guess it would be something along these lines but not sure how to format it.
[wpv-conditional if="( '[wpv-current-user]' eq 'example@email.com' )"]Show this text [/wpv-conditional]
Thanks!
Hello and thank you for contacting the Toolset support.
You can add the info argument to the shortcode to get the email. The code will be:
[wpv-conditional if="( '[wpv-current-user info="login"]' eq 'example@email.com' )"]Show this text [/wpv-conditional]
Check the shortcode documentation here https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-current-user
I hope this helps. Let me know if you have any questions.
That worked great thanks Jamal!
The last issue is using this shortcode my user can see the text but admins no longer see it. My fault I should have clarified so...
IF the current user's email address is example@email.com then show this text OR if the user is an editor or Admin also show this text.
You can compose several conditions on the same shortcode. Check this section of the article https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/#connecting-conditions
Please try this code and let me know if it helps:
[wpv-conditional if="( ( '[wpv-current-user info="login"]' eq 'example@email.com') OR ( '[wpv-current-user info="role"]' eq 'editor' ) OR ( '[wpv-current-user info="role"]' eq 'administrator' ) )"]
Show this text
[/wpv-conditional]