Problem:
I am trying to restrict a view to a subset of values for a field called positions:
1) When user open the the page, Views are filtered by:
field "positions" value is one of below two constants:
applicant, supervisor
2) When user change the field "Positions" in custom search form, views are filtered by user's chosen option
Solution:
That is expected result:
Users can no longer use the filter to show just caregivers or just applicants.
within Views's UI, you can setup only one of above two filters, you can not setup both two filters.
As a work around, you can try these:
1) Restore back your view's filter settings, filter the view by URL parameter "wpv-wpcf-hr-position"
https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/
2) When user open the page, use Views filter hook "wpv_filter_query" to trigger a PHP function
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
In this PHP function, do these:
1) Check if there is URL parameter "wpv-wpcf-hr-position"
http://php.net/manual/en/reserved.variables.get.php
if not, add a custom filter to query, filter the query by:
field "positions" value is one of below two constants:
applicant, supervisor
Relevant Documentation:
https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
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.
Our next available supporter will start replying to tickets in about 1.08 hours from now. Thank you for your understanding.
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: Asia/Hong_Kong (GMT+08:00)
This topic contains 3 replies, has 2 voices.
Last updated by 6 years, 6 months ago.
Assisted by: Luo Yang.