This should also work for Drupal 8 and Drupal 10 versions.
To get the value of a custom user field is pretty easy, see below:
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
// Textfield.
$name = $user->get('field_name')->value;
// Multiple values.
$names = $user->get('field_names')->getValue();