Home › Forums › Backend Issues (wp-admin) › update_field() with field type User › Reply To: update_field() with field type User
Get the value of the field without formatting and supply the post ID of the post that you want to update. Get Field: https://www.advancedcustomfields.com/resources/get_field/; Update Field: https://www.advancedcustomfields.com/resources/update_field/
// $post_id is the ID of the post you want to update
// 3rd arg == false tells ACF not to format the value
// $users will == an array or user IDs
$users = get_field('user_field_name', $post_id, false);
// add the users ID to the array
$users[] = $new_user_id_to_add;
// update the field
// $selector == the field key of the field to update
update_field($selector, $users, $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.