Home › Forums › Backend Issues (wp-admin) › taxonomy field filtered by taxonomy on the other taxonomy (yeah I know!) › Reply To: taxonomy field filtered by taxonomy on the other taxonomy (yeah I know!)
The answer to the question is, yes, this could be done, because you will have one Staff taxonomy field that matches each Role.
Using this filter https://www.advancedcustomfields.com/resources/acf-fields-taxonomy-query/ for each field.
ACF uses get_terms() https://developer.wordpress.org/reference/functions/get_terms/
Get terms supports meta queries https://developer.wordpress.org/reference/classes/wp_term_query/__construct/
So, when getting the staff terms you can use the ACF filter to only return staff members that have a specific taxonomy set by using a meta query on the role field.
However, you will still have a problem adding new staff members on the fly. The reason is that a new staff member will not have the correct roles set. This means that after saving the post the same staff will not be found for that role so it will not be displayed or selected.
To correct this you will need to create an acf/update_value filter for each field https://www.advancedcustomfields.com/resources/acf-update_value/
The update value filter will not alter the value. What the update value filter will do is add the new staff member to the correct role. You will need to look at the value, get the selected terms and then look at each term to see if it has the needed role. If it does not then you would use the update_field() function to alter the ACF field associated with the staff term to add the role.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.