Home › Forums › General Issues › Unable to write multiple values ACF user field back to DB › Reply To: Unable to write multiple values ACF user field back to DB
It is not 100% clear by your question what type of field you’re using. If you are working with a user field, a user field stores only the User ID values in and array. The same is true of a relationship field if that is what you’re using. When you use update_field()
you need to supply ACF with the value as it needs to be stored, in this case an array of ID values.
You can get the current value unformatted by using the 3rd parameter.
$current_mentees = get_field('current_mentees', $mentor_post_id, false);
then you can add a new ID to the array
$current_mentees[] = 125; // or whatever code your using to get the ID to add
then you update the field
update_field('current_mentees' , $current_mentees , $mentor_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.