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 6 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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é : 

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par tony Il y a 5 années et 6 mois.

Assisté par: 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

Les langues: Anglais (English )

Fuseau horaire: 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

Ce ticket est maintenant fermé. Si vous êtes un client de Toolset et que vous avez besoin d'aide, veuillez ouvrir un nouveau ticket d'assistance