This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » eZ Publish 5 Platform » User self edit.

User self edit.

User self edit.

Tuesday 29 May 2018 10:19:10 am - 3 replies


I have a problem with auto editing user account.

In a service, I have this piece of code that changes the current user's account.

        $user = $this->repository->getCurrentUser();
        $userContent = $contentService->loadContentByContentInfo($user->contentInfo);
        $draft = $contentService->createContentDraft($userContent->contentInfo);
        $struct = $contentService->newContentUpdateStruct();
        $struct->setField('my_field', $my_new_value);
        $contentService->updateContent($draft->versionInfo, $struct);

And in response I have the following error 500:

> User does not have access to 'edit' 'content' with: contentId '11290'
500 Internal Server Error - UnauthorizedException

However, my user has the right to "user/selfedit".

On the other hand I do not see how to give him the right of edition on the contents of type user but only himself.

By the way, I would like to skip the rights management at the service level..

Note. My service is called from a legacy BO

Modified on Tuesday 29 May 2018 10:20:24 am by Rémy PHP

Tuesday 29 May 2018 10:44:40 am

I tried to handle it at the legacy module level.

$popinService = $container->get('mybundle.popin_service');
$curent_user = eZUser::currentUser();
$admin_user = eZUser::fetch(14);
eZUser::setCurrentlyLoggedInUser($admin_user, $admin_user->id());
try {
    $data = $popinService->accept($contentObjectID, $curent_user->id());
} catch (Exception $e) {
    echo $e->getMessage();
    $data = false;
eZUser::setCurrentlyLoggedInUser($curent_user, $curent_user->id());


But without success

Tuesday 29 May 2018 11:16:38 am

If I give the rights to the users it works. But that's not an option.

  • content     edit     Class( User )
  • content     versionread     Class( User )

Tuesday 29 May 2018 11:24:08 am

Got it !



            $adminUser = $this->repository->getUserService()->loadUser(14);
            $currentUser = $this->repository->getUserService()->loadUser($userContent->id);
            $draft = $contentService->createContentDraft($userContent->contentInfo);
            $struct = $contentService->newContentUpdateStruct();
            $struct->setField('popin_accepted', $value);
            $contentService->updateContent($draft->versionInfo, $struct);
            /*$userContent =*/ $contentService->publishVersion($draft->versionInfo);


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

36 542 Users on board!

Forums menu

Proudly Developed with from