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 3 années et 10 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.

Marqué : 

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

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

Assigned support staff: 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