PS. as per my question above in this tread. I was expecting the output of the met_query to be a full user_object but the key was just an ID. AFC builds the user object from the stored ID when get_field is called. I bet your issue is similar.
Two things you can try:
1. value does accept an arra so that may help matching on a post_object -> ‘value’ => array(‘auth1′,’auth2’),
2. Ensure the key author matches the query_var type. e.g. if author is name you may need to convert it to ID etc.
Basically check what exact data the AFC field is saving… It’s not always what you expect because the AFC output is an abstracted version of the data and not the raw values which meta_query uses for matching. Look at author key->values in the DB or var_dump using get_post_meta not get_field.
Thanks John.
I found 2 things in my search just now:
1. ACF 4 – Meta rule plugin works well https://wordpress.org/plugins/advanced-custom-fields-meta-location-rule/
2. ACF 5 – Like John said:
– I made a taxonomy called “template”
– and taxonomy field that updates the post terms on each page
– then “post taxonomy” is equal to “template type” on template field groups
Works like a charm!
Yeah this is a major limitation. It’s stopped me from using repeater with WYSIWYG. I really hope there can be a solution at some point. Next time a have a bit a break from work I’ll take a look at this issue in detail.
FYI – i just figured out why this does work. The saved value for this field type doesn’t contain the full user object so like compare works if you use userID
I have a similar case, but the key is a User object field called “consultant”. A var_dump of the get_field results in a array of user data.
Is type of field serialize data too?
This LIKE compare doesn’t seem to work, but then again neither does the “IN” which I would have thought was the correct compare?
Details here -> http://stackoverflow.com/questions/26768230/wordpress-meta-query-on-user-object
Thanks
No I never solved this issue.. sorry cannot give you any insight into where the issue maybe be coming from.
I got this working so thought I’d share code:
// instance vars.
$uid = $_POST['user_id']; // current user ID
$field_key = "field_5344787df3a9b"; // ACF field name
$post_id = $_POST['post_id']; // Post ID of draw to update
// Get member_entries field
$value = get_field($field_key, $post_id);
$new_value = array();
foreach ( $value as $id => $entry ) {
if ($entry['user_id'] == $uid) continue;
$new_value[$id] = $entry;
}
$status = update_field( $field_key, $new_value, $post_id );
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.