Home Forums General Issues Update_Field not working Reply To: Update_Field not working

  • Hi @guit4eva

    If the field didn’t exist beforehand in the DB (created in some other way than this) you need to use the field key rather than the field name as the first parameter for update_field().

    As a sidenote you do not need to concatenate the strings with empty ” at the end 🙂


    $displayed_user = 'user_' . bp_displayed_user_id(); // Get User ID
    $assessments_repeater = get_field( 'assessments', $displayed_user ); // Get Assessments Repeater field
    $ass_latest = end($assessments_repeater); // Get last row of repeater
    $current_level = get_field( 'current_level', $displayed_user ); //Get current level
    $ass_latest_rating = $ass_latest['ass_rating']; // Get latest rating
    $ass_at = $ass_latest['assessed_at']; // Get latest level assessed at
    if( $ass_latest_rating != 1 ) {
      update_field( 'fieldkey goes here', $ass_at, $displayed_user );