Home › Forums › General Issues › Hide values that have been selected in other post › Reply To: Hide values that have been selected in other post
Hi there!
If I understand correctly, you want to filter all tracks that have a certain condition already defined on the select.
I did something similar using: acf/fields/post_object/query (https://www.advancedcustomfields.com/resources/acf-fields-post_object-query/).
You need to a filter that will call the function that will narrow down the choices using a query.
In my case (this is OOP code but you should get the gist), I added the filter:
$action_filter_register->add_filter( 'acf/fields/post_object/query/name=client_match_object_field', Match::class, 'filter_participant_options', 10, 3 );
And then defined the function that did the trick:
public function filter_participant_options( $args, $field, $post_id ) {
$allowed_states = EntityStates::get_allowed_states_for_matching();
$args['numberposts'] = -1;
$args['meta_query'] = array(
array(
'key' => '_state',
'value' => implode( ',', array_keys( $allowed_states ) ),
'compare' => 'IN',
),
);
return $args;
}
Hope this helps!
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.