I'm trying to figure how to make a custom user field searchable, and sortable, in admin users panel.

My custom field stores a client ID. As I can have multiple accounts per ID, i'd like to make this custom field searchable, and sortable.

I can't find any documentation, all I can find is frontend oriented content, can someone explain how does administrator search bar works, how to index fields, and maybe custom fields ?

Code to display a custom user field in admin panel (users list):

    //to get fields by name
    function getValueByFieldName($customFields, $field_name) {
        foreach ($customFields as $field) {
            if ($field->name == $field_name){
                return $field->value;
<?php foreach ($this->items as $i => $item) :
    $canEdit   = $this->canDo->get('core.edit');
    $canChange = $loggeduser->authorise('core.edit.state',  'com_users');
    $customFields = FieldsHelper::getFields('com_users.user', JFactory::getUser($item->id), true); 
    $field_name_value = getValueByFieldName($customFields, 'field_name');
    // If this group is super admin and this user is not super admin, $canEdit is false
    if ((!$loggeduser->authorise('core.admin')) && JAccess::check($item->id, 'core.admin'))
        $canEdit   = false;
        $canChange = false;
    <tr class="row<?php echo $i % 2; ?>">
        <td class="center">
            <?php if ($canEdit || $canChange) : ?>
                <?php echo JHtml::_('grid.id', $i, $item->id); ?>
            <?php endif; ?>
        <td class="center">
            <?php echo $custom_field_value; ?>
  • Thanks for asking in JSE. Please take our tour while you wait for feedback/support. Apr 11, 2022 at 12:33
  • I don't believe you will be able to make them searchable very easily as the custom fields are stored in the com_fields component table(s) while the core User fields are in the com_user tables. I would think you would need a very modified Model in com_user to combine the data from the various tables so that it can be searched. I am not sure that you can override or extend the core com_user Models. Sorting would also require changes tot he default com_user Model.
    – Irata
    Apr 11, 2022 at 21:27
  • maybe the simpliest solution is to modifying the filter_search bar query ?
    – Natwork
    Apr 12, 2022 at 9:10


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.