eZ Community » Forums » Extensions » Creating users with ezxmlinstaller
expandshrink

Creating users with ezxmlinstaller

Creating users with ezxmlinstaller

Wednesday 22 August 2012 8:54:08 pm - 1 reply

Hello,

Can anyone tell me how to correctly create users with ezxmlinstaller?

I can generate XML to create user contentobjects, with correctly assigned first and last name, but I cannot find the correct XML node to use to assign the login and the email address.

Can anyone help?

Thanks

 

Edit:

 

Ok I found the answer myself

 

 <ContentObject owner="14" creator="14" contentClass="user" section="2" remoteID="xxxxx">
                     <Attributes>
                         <first_name>first</first_name>
                         <last_name>name</last_name>
             <user_account login="mylogin" email="email@email.com" password="mypasswordinclear" />
                     </Attributes>
                 </ContentObject>

Modified on Friday 24 August 2012 10:14:09 am by H R

Friday 24 August 2012 10:39:17 am

I could be wrong, but I do not believe this is possible by default as there is no handler for a user. This is because creating a user is a two-step process:

  1. Create a contentobject of type user
  2. Attach an ezuser object to that content object (where username and password are stored)

The ezcreatecontentobject install handler is unaware of how to handle a user creation - but I can see how it was graceful enough to do the first part for you.

 

It should be easy enough to copy and extend the ezcreatecontentobject installerhandler (or reference it or extend it in your own class) to create an ezcreatuser install handler.
The general steps would be:

  • do the exact same steps as in the ezcreatecontentobject handler
  • Then create a user object referencing the content object

This is more convoluted than needed if you try to re-use ezcreatecontentobject since one of the methods has no return value and it is also hard-coded for 'contentobject'

If you want to try to make your own handler, I can provide you with a freestanding function that creates a user that you can use as a base.

Modified on Friday 24 August 2012 10:39:40 am by David Ennis

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from