Jump to content

How to get and edit a single user


Eltom
 Share

Recommended Posts

Hi all,

as I understand the users concept in processwire, every user is a page with a template "user", right?

So a 

foreach($pages->find("template=user, include=all") as $myuser) {
...
} 

will cycle through all the users on my system ( I already did that, seems to work). 

Now I want to edit a specific user.

In my understanding a

$myuser = $pages->find("template=user,name=$someusername); 
$myuser = $pages->find("template=user,id=$someuserid); 
....

gets a single user, but this seems wrong.

I'd love to get a specific user object to edit (name, password etc.) it and save it, but I don't know how to access it.

Regards, Thomas

Link to comment
Share on other sites

Hi Eltom,

Using $pages->find() will always return a PageArray. To get a single page, use $pages->get().

For users, there's also the $users API variable available:

$u = $users->get('username'); // Search by Username, ID or Selector
$u = $users->find('selector'); // Search multiple users by Selector

But specifing the user template as you did above is also fine, I guess :)

  • Like 1
Link to comment
Share on other sites

Thanks, Wanze. Finally I found $users..... :'( I always checked on $user and there was no find() or get(), which is logical, because it's "my own user object".

@all:

Thank you for all the help I received regarding Users and Pages in this and other Threads! With your help I was able to implement some nice User-Management for my client!

*THUMBSUP*  :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...