Home › Forums › Backend Issues (wp-admin) › Add-filter
Hello, can someone help me with this please, i’m stuck for weeks:
I have 2 acf fields:
First is ‘brands’ of type checkboxes that i populate dynamically with a list of choices.
Second is ‘brand’ of type select that I want to populate dynamically with values that where checked in the brands checkbox.
All good if I change data from post, but when I want to add values to them from an import script that I have, some problems shows up:
with thie line of code:
update_field(‘brands’,$brands,$post_id);
I added the selected checkboxes. it’s working but when the add_filter is called to populate the brand field with brands selected checkboxes is not working and I print_r the brands field object in add_filter for brand, this is the output:
Array
(
[key] =>
[label] =>
[name] =>
[_name] =>
[type] => text
[order_no] => 1
[instructions] =>
[required] => 0
[id] => acf-field-
[class] => text
[conditional_logic] => Array
(
[status] => 0
[allorany] => all
[rules] => 0
)
[default_value] =>
[formatting] => html
[maxlength] =>
[placeholder] =>
[prepend] =>
[append] =>
[value] =>
)
So way is the field like this? Any ideas? Tips something are all welcome.Thanks!
When populating fields with an import tool it or script it needs to be an import that understands how ACF fields are saved. It isn’t the field value but another hidden custom field that is a pointer for ACF to understand what type of field it is.
Let’s say that your field name is “field_name”. The database will have 2 entries. The first is your field name with your value and the second will be “_field_name” and the value of this field is the ACF field key for this field. It gets more complex for some types of fields.
The topic ‘Add-filter’ is closed to new replies.
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.