Skip Navigation

[Resolved] Views filter: “Post author is NOT the same as the logged in user”

This thread is resolved. Here is a description of the problem and solution.

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 4 years ago. 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 – 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)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by tony 4 years ago.

Assigned support staff: Shane.

Author
Posts
#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: English (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