Hi,
sorry but we will not add this feature because we do not want to expose usergroups in frontend.
Although is this solution up there still working. It doesn't for me.
try with this code:
<?php
$db=JFactory::getDbo();
$query=$db->getQuery(true);
$query->select('title')->from('#__usergroups')->where('id IN ('.implode(',',$this->user->getAuthorisedGroups()).')');
$db->setQuery($query);
$result=$db->loadColumn();
echo '<div><b>Member of:</b> '.implode(', ',$result).'</div>';
?>
As a feature I would like to have it as a custom field rather than a fixed info beneath the name.
The faster way is to use a plugin like Sourcerer (
https://www.regularlabs.com/extensions/sourcerer) and put the code below in HTML delimiter field type (see Screenshot)
{source}
<?php
$db=JFactory::getDbo();
$user = JFactory::getUser(JRequest::getVar('id',null));
$query=$db->getQuery(true);
$query->select('title')->from('#__usergroups')->where('id IN ('.implode(',',$user->getAuthorisedGroups()).')');
$db->setQuery($query);
$result=$db->loadColumn();
echo implode(', ',$result);
?>
{/source}
NOTES:
- HTML delimiter field type allow you to put a static test in a field position (
http://docs.easy-profile.com/index.php/article/html-delimiter-field-type)
- Sourcerer plugin allow you to use PHP code in the all parts that load Joomla content plugins (like HTML delimiter field type)