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);
    $post_id2 = 'user_' . $user1;
    $value2 = get_field($field_key, $post_id2);
    $value2[] = array("user" => $user2);