Help with filterByAttribute()
Permalink
I want to be able get a list of users who have a specific value for an attribute I created.
I am trying to use the "filterByAttribute()" function found here:
http://www.concrete5.org/documentation/developers/permissions/user-...
As an example I have an attribute with a handle of "my_attribute_handle" and it currently has the value of "5".
however my $ful variable is NULL, even though I know there are several users with the attribute "my_attribute_handle" with the value of "5".
Thanks for any help.
I am trying to use the "filterByAttribute()" function found here:
http://www.concrete5.org/documentation/developers/permissions/user-...
As an example I have an attribute with a handle of "my_attribute_handle" and it currently has the value of "5".
Loader::model('user_list'); $ul = new UserList(); $ful = $ul->filterByAttribute('my_attribute_handle', '5', '='); var_dump($ful);
however my $ful variable is NULL, even though I know there are several users with the attribute "my_attribute_handle" with the value of "5".
Thanks for any help.
have you tried $ul->get()?
Thank you, this was the missing link
Try this:
Loader::model('user_list'); $ul = new UserList(); $ul->filterByAttribute('my_attribute_handle', '5', '='); $ul->get(); var_dump($ul);
It's not by any chance a <select> type attribute is it? I had endless fun with those. I found some documentation somewhere that said to do this:
which worked fine in my case.
$pl->filterByAttribute('color', "%\nGreen\n%', 'like');
which worked fine in my case.
The filters just build the query you still have to execute the query and get the results. This is so that you can add various sorts and filters before grabbing the list.
You can also use the more leet version of
Loader::model('user_list'); $ul = new UserList(); $ul->filterByAttribute('my_attribute_handle', '5'); // This right here $users = $ul->get(); // then do the whole foreach($users as $user) { // do stuff }
You can also use the more leet version of
Loader::model('user_list'); $ul = new UserList(); // magic $ul->filterByUserMyAttributeHandle('5'); $users = $ul->get();
Thank you, I read about these "Magic" functions, however was missing the $ul->get(), so that didn't work either. lol