Skip Navigation

[Résolu] Views filter: « Post author is NOT the same as the logged in user »

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Check if current user is the same as the author of a post.
Solution:

This can be done by using our views conditional code.
[wpv-conditional if="( '[wpv-current-user info="id"]' eq '[wpv-post-author format="meta" meta="ID"]' )"]

Some Content

[/wpv-conditional]

This support ticket is created Il y a 5 années et 5 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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

Supporter timezone: America/Jamaica (GMT-05:00)

Marqué : 

This topic contains 2 réponses, has 2 voix.

Last updated by tony Il y a 5 années et 5 mois.

Assisted by: Shane.

Auteur
Publications
#1147144

Tell us what you are trying to do?
I want to add a filter to a View so that any posts with the same author as the logged in author are excluded.

Is there any documentation that you are following?
https://toolset.com/documentation/user-guides/filtering-views-query-by-author/?utm_source=viewsplugin&utm_campaign=views&utm_medium=edit-view-author-filter&utm_term=Learn%20about%20filtering%20by%20Post%20Author

Is there a similar example that we can see?

What is the link to your site?

I can select posts where "Post author is the same as the logged in user" but what I need is to filter out posts where this is the case.

ie. How can I select posts where "Post author is NOT the same as the logged in user"?

I thought I might be able to get at the select code and change an = to ne.

Thanks
Tony

PS I meant to add - my current solution is to modify the display template with:
[wpv-conditional if="( '[wpv-current-user info="id"]' eq '[wpv-post-author format="meta" meta="ID"]' )" evaluate="false"]
[wpv-post-link]<br />
[/wpv-conditional]

#1147250

Shane
Supporter

Languages: Anglais (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tony,

Thank you for contacting our support forum.

Your current solution is the way to do it, unless you want to use a php hook, then this should be able to achieve the same results.

Thanks,
Shane

#1147252

Thanks Shane - I just wondered if there was a simpler way.
Kind regards
Tony

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.