<?php
/** In this scenario I have a custom field, type list with the name 'company-name' for my users **/
$user = JFactory::getUser();
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); // Load the custom fields helper
$ProfileFields = FieldsHelper::getFields('com_users.user', $user, true);
foreach ($ProfileFields as $field) {
if ($field->name === 'company-name') {
$companyName = $field->value;
$companyId = $field->rawvalue;
}
}