When you're editing a user then the contents of the Assigned User Groups tab is generated by the code in administrator/components/com_users/tmpl/user/edit_groups.php. As with all tmpl
files you can create an override within the administrator System / Administrator Templates / Atum Details and Files.
The code in edit_groups.php is just
echo HTMLHelper::_('access.usergroups', 'jform[groups]', $this->groups, true);
which runs the function usergroups()
within libraries/src/HTML/Helpers/Access.php.
So you can just move that function into edit_groups.php directly, remembering to include the appropriate use
statements, and setting manually the parameters to that function.
The code gets a list of the usergroups on the system and cycles through them to output the checkboxes for each. I've just included code to skip over where the usergroup title is ABCAdmin. Obviously you'd need to do a bit more work to decide based on the current user whether the usergroup should be skipped or not.
use Joomla\CMS\Access\Access as AccessCheck;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\UserGroupsHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
$name = 'jform[groups]';
$selected = $this->groups;
$checkSuperAdmin = true;
static $count;
$count++;
$isSuperAdmin = Factory::getUser()->authorise('core.admin');
$groups = array_values(UserGroupsHelper::getInstance()->getAll());
$html = [];
for ($i = 0, $n = count($groups); $i < $n; $i++) {
$item = &$groups[$i];
if ($item->title === "ABCAdmin") {
continue;
}
// If checkSuperAdmin is true, only add item if the user is superadmin or the group is not super admin
if ((!$checkSuperAdmin) || $isSuperAdmin || (!AccessCheck::checkGroup($item->id, 'core.admin'))) {
// Setup the variable attributes.
$eid = $count . 'group_' . $item->id;
// Don't call in_array unless something is selected
$checked = '';
if ($selected) {
$checked = in_array($item->id, $selected) ? ' checked="checked"' : '';
}
$rel = ($item->parent_id > 0) ? ' rel="' . $count . 'group_' . $item->parent_id . '"' : '';
// Build the HTML for the item.
$html[] = ' <div class="control-group">';
$html[] = ' <div class="controls">';
$html[] = ' <label class="form-check-label checkbox" for="' . $eid . '">';
$html[] = ' <input class="form-check-input" type="checkbox" name="' . $name . '[]" value="' . $item->id . '" id="' . $eid . '"';
$html[] = ' ' . $checked . $rel . '>';
$html[] = ' ' . LayoutHelper::render('joomla.html.treeprefix', ['level' => $item->level + 1]) . $item->title;
$html[] = ' </label>';
$html[] = ' </div>';
$html[] = ' </div>';
}
}
echo implode("\n", $html);