Help with filterByAttribute()

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:

As an example I have an attribute with a handle of "my_attribute_handle" and it currently has the value of "5".
$ul = new UserList();
$ful = $ul->filterByAttribute('my_attribute_handle', '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.

View Replies: View Best Answer
12345j replied on at Permalink Reply
have you tried $ul->get()?
ssmereka replied on at Permalink Reply
Thank you, this was the missing link
cgrauer replied on at Permalink Reply
Try this:
$ul = new UserList();
$ul->filterByAttribute('my_attribute_handle', '5', '=');
jero replied on at Permalink Reply
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:

$pl->filterByAttribute('color', "%\nGreen\n%', 'like');

which worked fine in my case.
mkly replied on at Permalink Best Answer Reply
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.
$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
$ul = new UserList();
// magic
$users = $ul->get();
ssmereka replied on at Permalink Reply
Thank you, I read about these "Magic" functions, however was missing the $ul->get(), so that didn't work either. lol