Get the custom fields created for User entity in Drupal8
You can filter the fields by checking which interface the field implements:

$fields = array_filter(
  \Drupal::service('entity_field.manager')-&gt;getFieldDefinitions('user', 'user'),
  function ($fieldDefinition) {
    return $fieldDefinition instanceof \Drupal\field\FieldConfigInterface;
  }
);


The second parameter of getFieldDefinitions() is the bundle. The user entity doesn't have bundles, but you can configure bundle fields. In this case the bundle name defaults to the entity id.