You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2023-08-24 17:20:23

Johan Romo
Member
From: Mexico City
Registered: 2022-10-27
Posts: 13

[SOLVED] Change user's entity using code

Hello there.


I was figuring out how to change an user's entity automatically, do it from php code or something else.


Currently, I am coding a plugin that adds a new page with a table to show the user's tickets, in this table there are tickets from five different entities, so, when the user clic on a ticket's link, I would like to change his entity to the ticket's one.


For our users is very hard to change entity between tickets, so if there is a way to do that it would be very helpful.


Thank you.

Last edited by Johan Romo (2023-09-15 19:41:34)

Offline

#2 2023-08-28 13:02:06

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,813
Website

Re: [SOLVED] Change user's entity using code

Plugins can call the "changeActiveEntities" static method in the Session class to change the current user's entity. The first parameter is the new entity ID and the second is a boolean to indicate if it should be recursive or not (see child entities).


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

#3 2023-09-15 19:40:54

Johan Romo
Member
From: Mexico City
Registered: 2022-10-27
Posts: 13

Re: [SOLVED] Change user's entity using code

Thank you cconard96 smile

Offline

Board footer

Powered by FluxBB