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'
)
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.