Skip Navigation

[Resolved] Show text to specific user

This support ticket is created 3 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 3 replies, has 2 voices.

Last updated by Jamal 3 years, 7 months ago.

Assisted by: Jamal.

Author
Posts
#1781537

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!

#1781617

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

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.

#1781715

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.

#1781811

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

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]
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.