Home Forums ACF PRO Adding a repeater row to a user Reply To: Adding a repeater row to a user

  • Hi James, I’ve taken your advice and I’m able to add to one repeater field on one user, but not another when the database isn’t initialized for that user.
    ( my code is below )

    $field_key = 'matched_users';
    //$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);
    echo '<br>added';

    How would i initialize the database? With a blank add_row/update_field?
    Thank you for your help so far.