<p>The underlying issue you're running into is this, which is an issue on both Craft 2 and 3 currently: <a href="https://github.com/craftcms/cms/issues/859" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/859</a></p>

<p>Can't think of a clean way to work around it, either.</p>

CC BY-SA 3.0
2018-02-13T22:29:11.463Z
2018-02-13T22:29:11.463Z
Brad Bell
<p>I have a plugin that is creating a custom field. I am using the <code>modifyUserSortableAttributes</code> method to make my field appear in the columns available for the Users Table and wanted to be able to sort and filter by this column. The field values is stored as a simple alphanumeric string. </p>

<p>More on hook/method at <a href="https://craftcms.com/docs/plugins/hooks-reference#modifyUserSortableAttributes" rel="nofollow noreferrer">https://craftcms.com/docs/plugins/hooks-reference#modifyUserSortableAttributes</a></p>

<p>Call in plugin code is:</p>

<pre><code>public function defineAdditionalUserTableAttributes()
{
    return array(
        'institution' =&gt; "Institution"
    );
}

public function modifyUserSortableAttributes(&amp;$attributes)
{
    $attributes['institution'] = Craft::t('Institution');
}
</code></pre>

<p>However, when I use this method whilst I can add the requisite column to my User table in the admin area and sort the fields alphabetically in ascending order I cannot sort the table by descending order. No errors turning up in the console or site logs. Any suggestions on resolving or debugging greatly appreciated.</p>

<p>Regards,</p>

<p>Cole</p>

<plugin-development><users><custom-fieldtype>
Getting `modifyUserSortableAttributes` to work during plugin development
# Getting `modifyUserSortableAttributes` to work during plugin development

(Asked by: username_0 on 2018-02-13)

I have a plugin that is creating a custom field. I am using the modifyUserSortableAttributes method to make my field appear in the columns available for the Users Table and wanted to be able to sort and filter by this column. The field values is stored as a simple alphanumeric string. 
More on hook/method at https://craftcms.com/docs/plugins/hooks-reference#modifyUserSortableAttributes
Call in plugin code is:
public function defineAdditionalUserTableAttributes()
{
    return array(
        'institution' => "Institution"
    );
}

public function modifyUserSortableAttributes(&$attributes)
{
    $attributes['institution'] = Craft::t('Institution');
}

However, when I use this method whilst I can add the requisite column to my User table in the admin area and sort the fields alphabetically in ascending order I cannot sort the table by descending order. No errors turning up in the console or site logs. Any suggestions on resolving or debugging greatly appreciated.
Regards,
Cole

**Tags:** plugin-development, users, custom-fieldtype


---

## 1 answers

### Answer by username_1 on 2018-02-13. Score: 1

The underlying issue you're running into is this, which is an issue on both Craft 2 and 3 currently: <https://github.com/craftcms/cms/issues/859>

Can't think of a clean way to work around it, either.


---

