Support

Account

Home Forums Backend Issues (wp-admin) Add-filter

Solved

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.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Add-filter’ is closed to new replies.