Members | filterByAttribute
Permalink
Working on modifying the members.php to filter by a custom attribute. I've been reading the forums but haven't found the solution. So far I've taken the members.php and put it in my single_pages folder and changed the $u= new User to $u=new UserList. I then have the filterByAttribute() in place but it still filters by first name. I've also tried to filter by group with no avail. Must be something I'm missing here. This is the code that's been modified on members.php.
<div class="ccm-profile-member-list"> <?php Loader::model('user_list'); $u = new UserList(); $u->filterByAttribute('golf_team'); foreach($users as $user) {
Check this page:http://www.concrete5.org/documentation/developers/permissions/user-...
I did something similiar but put the filtering in my controller (just as it is in the members.php controller) and I pretty much left the single page alone except for some minor changes. If you look at the members.php controller, they are filtering by keywords, but you should be able to just add in your filterByAttribute code.
It looks like you are not actually getting the users after filtering them as shown in the link from ceyhuncenger. Here is what I did in my controller code; I wanted to retrieve all users but you could put in a number of the items to get or get a page of users.
It looks like you are not actually getting the users after filtering them as shown in the link from ceyhuncenger. Here is what I did in my controller code; I wanted to retrieve all users but you could put in a number of the items to get or get a page of users.
public function view() { $userList = new UserList(); $userList->sortBy('lastname', 'asc'); $userList->filterByGroup('mygroupname'); $totalUsers = $userList->getTotal(); $users = $userList->get($totalUsers); // ....etc....
That makes much more sense now. Thank you!