Skip Navigation

[Gelöst] hide a ctp for to current user

This support ticket is created vor 6 Jahren, 3 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 3 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Luo Yang vor 6 Jahren, 3 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#1078712

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

#1079477

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

#1081118

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?

#1081126

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.