eZ Community » Forums » eZ Publish 5 Platform » How to create user in content object...
expandshrink

How to create user in content object (not in user group)

How to create user in content object (not in user group)

Thursday 25 June 2015 6:01:26 pm - 4 replies

We have such a structure of user section:

Users

     Business users [content type: User group]

             Company1 [content type: Company]

                    User 1 [content type: User]

 

UserService requires a list of user group as a parameter for creating users:

$user = $this->userService->createUser($userStruct, $userGroups)

 

But I need to specify parent location which is not user group, but usual content object.

 

Is it possible to create a user not in a user group?

Modified on Thursday 25 June 2015 6:02:25 pm by Andrey Astakhov

Thursday 25 June 2015 11:51:29 pm

Hello Andrey,

In the end, users are just like any other content object just of a specific / unique content class definition / content type which -must- contain usage of the 'User account' / ezuser datatype / field type.

https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Datatypes/User-account

You can create user content objects in any content tree node. I've done this myself. I don't remember but it might require some unique configuration with regards to some use case specific features (re: ini settings only). That said, I think you should just try to create a user object / location and review the results carefully.

Note that $userGroups can basically be any content object location object ...

I hope this helps!

Cheers,
Heath

Friday 26 June 2015 9:20:28 am

Hi Heath. Most probably this approach will work.

But I'm talking about new stack and we have very nice UserService there, that helps to manage users.

If both user and user group are just content (objects|items), then logically it might be possible to create them inside a content tree. However UserService can't do it because it requires user group always to be a parent of a user or a user group.

So, in my case I'll use ContentService to create a user as a usual content item, then I'll fetch this user and assign roles using UserService. A bit weird.

Friday 26 June 2015 11:28:58 am

Surprisingly I found out that I can pass content ids of any type as $userGroups here

$user = $this->userService->createUser($userStruct, $userGroups)

...and it works.

So I can use UserService.

 

Saturday 27 June 2015 5:22:19 pm

Hello Andrey,

Sorry I sounded like I was talking about legacy only.

I glad you were able to find a solution.

Best wishes

Cheers,
Heath

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from