eZ Community » Forums » Developer » Update User with User Service and...
expandshrink

Update User with User Service and Update Struct

Update User with User Service and Update Struct

Friday 04 March 2016 2:36:31 pm - 1 reply

Hello everyone,

I'm using the ez Publish community version 5.4.

Currently I'm implementing a LDAP user login. I want to update some user data like the passwort and the email-address of an existing user in ez with data from an active directory everytime a user logs in successfully with LDAP.

To accomplish this I'm using the user service of the repository-object and the UserUpdateStruct (code snippet):

$userService = $repository->getUserService();

$userUpdateStruct = $userService->newUserUpdateStuct();

$userUpdateStruct->password = 'password';

$userUpdateStruct->email = 'test@email.com';

$updatedUser = $userService->updateUser($ezUser, $userUpdateStruct);

 

So far this works for me. My problem is, if I change the email-address of a user in the backend, next time I'm updating the email-adress, it isn't changed. In the backend or the user-profile I see the old email-address. But when I use 

$userService->loadUserByLogin($ezUser);

$email = $ezUser->email;

the attribute email has the new updated address. 

 

I would be very thankful if someone could tell me how to update the email-address in the profile of a user and in the backend using the UserUpdateStruct. I know of a contentMetadataUpdatestruct and a contententUpdateStruct, which can be assigned to a UserUpdateStruct, but I don't know how to use them or if it would help me. I couldn't find anything about how to use them either. 

Thursday 21 July 2016 4:39:53 pm

Hello,
I had a similar problem.
I just added this:

$userUpdateStruct->contentUpdateStruct = $contentService->newContentUpdateStruct();

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from