Sorting by custom field

Permalink
I'm trying the following:

use Concrete\Core\User\UserList;
    $list = new UserList();
    $list->sortBy('sponsor');
    $endlist = $list->getResults();


But it errors out as it can't see the custom field 'sponsor'. Do I need to do this another way?

GeeEM
 
stewblack23 replied on at Permalink Reply
stewblack23
Hey GeeEm

Are you creating the custom field with code or in the concrete5 UI?
GeeEM replied on at Permalink Reply
GeeEM
I created custom attributes in the concrete5 UI.
enlil replied on at Permalink Best Answer Reply
enlil
Not sure if this works the same as for page attributes, but give this a try...
$list->sortBy('ak_sponsor');
GeeEM replied on at Permalink Reply
GeeEM
This actually does it. I'm getting a couple of minor issues, but it seems to do the sort as intended! Thanks.