Got it fixed. Pretty simple actually.
I moved the if part where the user get’s deleted to the bottom of the script.
foreach ($data as $gebruiker){
$username = $gebruiker['username'];
if ( username_exists( $username ) && $gebruiker['status'] == 'published' ){
$user = get_user_by( 'login', $username);
update_user_meta( $user->ID, 'import_1', $gebruiker['email'] );
}else{
$users = wp_insert_user(
array(
'user_login' => $gebruiker['username'],
'user_pass' => $gebruiker['password'],
'first_name' => $gebruiker['first_name'],
'last_name' => $gebruiker['last_name'],
'user_email' => $gebruiker['email'],
'display_name' => $gebruiker['first_name'] . ' ' . $gebruiker['last_name'],
'nickname' => $gebruiker['first_name'] . '' . $gebruiker['last_name'],
'role' => 'subscriber'
)
);
foreach ($data as $update_user) {
update_user_meta( $users, 'import_1', $update_user['first_name'] );
update_user_meta( $users, 'import_2', $update_user['last_name'] );
}
}if(username_exists( $username ) && $gebruiker['status'] == 'archived'){
require_once(ABSPATH.'wp-admin/includes/user.php' );
$user = get_user_by( 'login', $username);
wp_delete_user( $user->ID );
}