Navigation überspringen

[Gelöst] conditional output, where current user is post author

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
The user would like to display some output when the current user is the author of the post.

Solution:
Note that the wpv-current-user short code does not accept "user_login" in info attribute. It accepts "login" instead.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#vf-153354

This support ticket is created vor 4 Jahren, 9 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.

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)

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

Zuletzt aktualisiert von Lara vor 4 Jahren, 9 Monaten.

Assistiert von: Jamal.

Author
Artikel
#1564995

Tell us what you are trying to do?


<!-- Conditional output for user, who is not the post author of the current post in the loop -->

[wpv-conditional if="( '[wpv-current-user info='user_login']' ne '[wpv-post-author format='meta' meta='user_login']' )"][cred-relationship-form form='relationship-form-reitanlage-benutzer' child_item='$current'][/wpv-conditional] 

<!-- Conditional output for user, who is the post author of the current post in the loop -->
  
[wpv-conditional if="( '[wpv-current-user info='user_login']' eq '[wpv-post-author format='meta' meta='user_login']' )"][cred-relationship-form form='relationship-form-reitanlage-benutzer-author' child_item='$current'][/wpv-conditional]
    

Somehow it doesn't work. I think there is a mistake in it. But I can't figure out, what's wrong.

Is there any documentation that you are following?
Yes. But I can't remember where I found it.

Is there a similar example that we can see?
See above

What is the link to your site?
versteckter Link

#1565301

Hello and thank you for contacting the Toolset support.

You will need to change "user_login" to "login" in your condition shortcode. Your code will be:

<!-- Conditional output for user, who is not the post author of the current post in the loop -->
 
[wpv-conditional if="( '[wpv-current-user info='login']' ne '[wpv-post-author format='meta' meta='user_login']' )"][cred-relationship-form form='relationship-form-reitanlage-benutzer' child_item='$current'][/wpv-conditional] 
 
<!-- Conditional output for user, who is the post author of the current post in the loop -->
   
[wpv-conditional if="( '[wpv-current-user info='login']' eq '[wpv-post-author format='meta' meta='user_login']' )"][cred-relationship-form form='relationship-form-reitanlage-benutzer-author' child_item='$current'][/wpv-conditional]
    

Check the shortcode documentation on this page for the supported attributes for the shortcode "wpv-current-user"
https://toolset.com/documentation/user-guides/views/views-shortcodes/#vf-153354

I hope this helps. Let me know if you have any doubts.

#1565361

Thanks you so much, Jamal. Now it works 🙂