renobird Posted September 12, 2012 Share Posted September 12, 2012 Hello all, A bit dense today, so hopefully someone can help me. I'm trying to show a list of all the roles a user has using the API. $users = $pages->find("parent=/processwire/access/users/"); foreach ($users as $user) { echo $user->name . " - " . $user->roles . "<br />"; } $user->roles returns a page array, so I get something like 1015|2263|2273 What I need is the name of the role instead of the page ID. Duh! $user-roles is an array, need to use foreach to return the name. Sorry, told you I was being dense today. As you were. 1 Link to comment Share on other sites More sharing options...
ryan Posted September 12, 2012 Share Posted September 12, 2012 Also want to mention that you don't need to do the $pages->find(); because ProcessWire already provides you with a $users API variable. The $users API variable is like a special $pages API variable that only acts on users. Though unlike the $pages API variable, you can foreach($users). 1 Link to comment Share on other sites More sharing options...
renobird Posted September 12, 2012 Author Share Posted September 12, 2012 Thanks Ryan, Not sure what I was thinking this morning — thinking too much about the iPhone 5 I guess. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now