Leave a Reply

1 comment

  1. You are checking if the field is empty. Try to update it if its empty as well

     if( trim( $attachment[ $field ] ) == '' ) $post[ 'errors' ][ $field ][ 'errors' ][] = __( 'Error! Something went wrong.' );
     else update_post_meta( $post[ 'ID' ], $key, $attachment[ $field ] );
    

    Try

    if( isset( $attachment[ $field ] ) ) {
                if( trim( $attachment[ $field ] ) == '' )
                $post[ 'errors' ][ $field ][ 'errors' ][] = __( 'Error! Something went wrong.' );
                endif;
                update_post_meta( $post[ 'ID' ], $key, $attachment[ $field ] );
            }