Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonypartridge/b4559053f4af769204785bdb5e7d1ead to your computer and use it in GitHub Desktop.
Save tonypartridge/b4559053f4af769204785bdb5e7d1ead to your computer and use it in GitHub Desktop.
<?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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment