// Translate the empty value '' of language selects to an unset field.
foreach (['preferred_langcode', 'preferred_admin_langcode'
] as $field_name) { if ($form_state->
getValue($field_name) === ''
) { $account->
$field_name = NULL;
} } // Set existing password if set in the form state.
$current_pass =
trim($form_state->
getValue('current_pass', ''
));
if (strlen($current_pass) > 0
) { $account->
setExistingPassword($current_pass);
} // Skip the protected user field constraint if the user came from the
// password recovery page.
$account->_skipProtectedUserFieldConstraint =
$form_state->
get('user_pass_reset'
);
return $account;
} /**
* {@inheritdoc}
*/