Problem:
I want to show all view results in a published status to all guest users.
On the same page, I want to show all view results in a pending status to administrator only.
I have thought of two ways of implementing this:
1) Use two different views in the same page with two different filters, one filtering for post status = published, and the other one for post status=pending. The problem I'm facing is that when I update a view's filter, it also updates the other view's filter on the same page.
2) Use the save view but dynamically change the post status filtering based on whether the user is admin or not. Problem is that I don't know how to do this.
Another solution I guess would be I filter both for Published and Pending status. Then in the view's logic, I put a condition to show the right post status to the right set of users. That should do, though my preference would have been two separate views.
Solution:
Regarding the option(1), I assume that you are building these views with Blocks, right? We recently had a similar case(views filters overwritten) and it will be fixed soon.
I'll suggest, putting each view in a separate content template(the content template must not be assigned to any post type). This way, the views' filters won't be overwritten across each other.
Regarding the option(2), this will require custom code, hooked to the wpv_filter_query filter and modifying the query arguments "post_status" accordingly.
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
The 3rd option is not a good solution. Because the view query will always return all the posts, instead of returning just what is needed. And this can have a performance hit on the view/page.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
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 vor 4 Jahren, 10 Monaten.
Assistiert von: Jamal.