Home › Forums › ACF PRO › Adding a repeater row to a user › Reply To: Adding a repeater row to a user
Hi James, I’m now using the field key but I still cannot add new fields to new users without adding a field in the back-end first.
How would I resolve this?
EDIT: A bit of code I wrote wasn’t making this function, the above solution works.
$field_key = 'field_570d00f097fbd';
//$user1 is user1's ID
//$user2 is user2's ID
echo 'adding field...<br>';
$post_id1 = 'user_' . $user2;
$value1 = get_field($field_key, $post_id1);
$value1[] = array("user" => $user1);
update_field($field_key,$value1,$post_id1);
$post_id2 = 'user_' . $user1;
$value2 = get_field($field_key, $post_id2);
$value2[] = array("user" => $user2);
update_field($field_key,$value2,$post_id2);
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.