Support

Account

Home Forums General Issues Setting User & Post Object Values in admin Using wp_insert_post Reply To: Setting User & Post Object Values in admin Using wp_insert_post

  • The problem is that when inserting values in this manor that the acf field key reference is not being added to the database. For each field there is an acf field key reference. This is explained briefly on this page https://www.advancedcustomfields.com/resources/update_field/

    Updating for field name only works for basic text type fields but will not work with complex fields. The field key reference is required for ACF to understand what the field value represents.

    You can insert the values the way you are doing as long as you also insert the field key reference. Let’s say (example) that the field key for “team_member” is “field_XXXXXX”

    
    //...
            'meta_input' => array( 
              'email' => $data['email'], 
              'first_name' => $data['FNAME'], 
              'last_name' => $data['LNAME'], 
              'company' => $company_id, 
              'contact_name' => $data['CONTACTNAM'], 
              'team_member' => $team_member_id,
              '_team_member' => 'field_XXXXXX'
          )