Trying to list all the name of users in a particular group.
Permalink 1 user found helpful
I have a group called Test_Group, and a custom attribute with handle full_name. I would like to list out the value of full_name for all the users in the this group. Here is my attempt so far:
The problem is
echo $ui->getAttribute('full_name');
gives the error:
Fatal error: Call to a member function getAttribute() on a non-object
I tried wrapping it in an if statement:
But then nothing at all prints.
The problem is
echo $ui->getAttribute('full_name');
gives the error:
Fatal error: Call to a member function getAttribute() on a non-object
I tried wrapping it in an if statement:
But then nothing at all prints.
I had originally thought that, but it gives the error:
Fatal error: Call to a member function getUserID() on a non-object
putting
again results in no output.
Just to be clear, there is currently only one user in this group, called test_user with full name Test User.
Fatal error: Call to a member function getUserID() on a non-object
putting
if(is_object($u)){ $ui = UserInfo::getByID($u->getUserID()); }
again results in no output.
Just to be clear, there is currently only one user in this group, called test_user with full name Test User.
Try this loop:
Credit: http://www.concrete5.org/community/forums/customizing_c5/user_list-...
foreach($ul->getPage() as $u) { $ui = UserInfo::getByID($u->getUserID()); echo "First Name: " . $ui->getAttribute('full_name') . "<br />"; }
Credit: http://www.concrete5.org/community/forums/customizing_c5/user_list-...
It works! Thank you.
I'm having an additional problem with this - it only lists the first ten users in the group (which now has 28 members).
My code is now:
For some reason this userList $ul has only ten elements - trying to access anything after the tenth returns null. I'm stumped as to why.
My code is now:
Loader::model('user_list'); Loader::model('userinfo'); $ul = new UserList(); $ul->filterByGroup("Test_Group"); foreach($ul->getPage() as $u) { $ui = UserInfo::getByID($u->getUserID()); $name = $ui->getAttribute('full_name'); echo "Name: ".$name."</br>"; }
For some reason this userList $ul has only ten elements - trying to access anything after the tenth returns null. I'm stumped as to why.
The default 'pagination' on the user_list is 10 so try tossing this in just before the foreach loop :
You can also try putting this in at the bottom of the page if that makes sense:
See this thread:
http://www.concrete5.org/community/forums/customizing_c5/how-to-dis...
$ul->setItemsPerPage( 100 ); //set to whatever value
You can also try putting this in at the bottom of the page if that makes sense:
<?php echo $ul->displayPagingV2()?>
See this thread:
http://www.concrete5.org/community/forums/customizing_c5/how-to-dis...
I think you can use 'all' in place of a numeric value as well
"All" doesn't seem to work (with or without quotes).
Yes, that fixed it. Once again, thank you for your prompt reply!
$u is the individual user from which you are pulling the user attribute 'full_name'.