Home › Toolset Professional Support › [Resolved] hide a ctp for to current user
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: Asia/Hong_Kong (GMT+08:00)
Tagged: Types plugin
This topic contains 3 replies, has 2 voices.
Last updated by Luo Yang 6 years, 3 months ago.
Assisted by: Luo Yang.
Tell us what you are trying to do?
I want to have a form where a "User A" can put in the email-adress or username (Username would be better) from "User B".
When the ctp is created from "User A" - "User B" cannot find the cpt which "User A" has generated.
To make it short: User A is hiding his Post Type from User B.
All other Users C,D,E... can see and find the post type from User A. It is only hidden for User B
I would like to do this with the if conditionals. But how does toolset check the current user?
with his email/username/id?
Would this work with this conditional?
Let´s say this field "wpcf-custom-email" is the input field for "User A" to put in e.g. the email or username for "User B" so the post is not shown to him.
[wpv-conditional if="( $(wpcf-custom-email) eq ''[wpv-current-user]' )"evaluate="false"][/wpv-conditional]
thanks and cheers
Hello,
Yes, you are right, you can get the information of current user with shortcode [wpv-current-user], and get the email of current user like this:
[wpv-current-user info="email"]
So you can try setup the wpv-conditional shortcode like this:
[wpv-conditional if="( $(wpcf-custom-email) eq '[wpv-current-user info="email"]')" evaluate="false"] ... [/wpv-conditional]
More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-current-user
Hey,
does this also work with the username or only with the email?
And does this conditional also work in a search view? So this post is hidden for the current user?
For current user's username, you can get the value with shortcode:
[wpv-current-user info="login"]
then use it in [wpv-conditional] shortcode in same way, if you are going to check the email and username in same wpv-conditional shortcode, you can try this:
[wpv-conditional if="( ($(wpcf-custom-email) eq '[wpv-current-user info="email"]') OR ($(wpcf-custom-email) eq '[wpv-current-user info="login"]') )" evaluate="false"] ... [/wpv-conditional]
Yes, it is possible to use it in a search view too.