You have to define your options as “value : label, where value is then your taxonomy id. For example, for Sex I have 3 options:
1 : Woman
2 : Man
3 : Trans
This returns an id.
Whereas if you define it like this:
woman : [anything except the word woman]
man : [anything except the word man]
trans : [anything except the word trans]
then it returns a string.
So it depends on what value $posted_roles is.
If it’s an ID, you need to change this
$term_id = get_term_by( 'name', $posted_roles, 'asproducts_cats' );
$term_id = get_term_by( 'id', $posted_roles, 'asproducts_cats' );
which should then match your taxonomy id of course.
So how did you define your options ?
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!
© 2022 Advanced Custom Fields.