Hi,
i’ve custom taxonomy used in users profile with checkbox (six option) . When i save it insert in the table wp_usermeta this serialized value:
a:1:{i:0;s:1:”2″;} – option 1
a:1:{i:0;s:1:”6″;} – option 2
a:1:{i:0;s:1:”3″;} – option 3
a:1:{i:0;s:1:”4″;} – option 4
a:1:{i:0;s:1:”5″;} – option 5
a:1:{i:0;s:3:”846″;} – option 6
This is the query to get all users with one checked option
// id of the single term custom taxonomy
$term_id = term_exists( $area );
$args = array(
‘who’ => ‘authors’,
‘order’ => ‘ASC’,
‘meta_query’ => array(
array(
‘key’ => ‘custom taxonomy’,
‘value’ => $term_id,
‘compare’ => ‘LIKE’
)
)
);
If i want all users with option 3 checked i get users with option 6 checked too.
I noticed that when i save user with option 6 it write in the table:
a:1:{i:0;s:3:”846″;}. If i change s:3 in s:1 it works fine.
It’s a save error?
I’ use last version of ACF pro and 4.3.1 of wordpress
I hope I have explained well
Because you are doing LIKE 3
for example when you should be doing LIKE "3"
Your value that you’re searching for should be
'value' => '"'.$term_id.'"',
so that you are searching for exactly the term ID enclosed in quotes.