I’m trying to valid my incoming order by simply putting in my trigger “$object.valid(…)” since $object is from that class but the method requires a User.
I suppose they ask for a user that would have the right to validate an order, but how could I fetch it ?
That’s right, you need a user with the required rights. This user is also recorded as being the one who did the validation. If you create a user for this purpose (and set its rights accordingly), you can fetch it like this:
require_once DOL_DOCUMENT_ROOT.‘/user/class/user.class.php’;
$user = new User($this->db);
$user_id = $user->findUserIdByEmail(“user@example.com”);
$user->fetch($user_id);
BTW all class descriptions are available under this link: https://doxygen.dolibarr.org/ (if you did not come across this already).
Thank you, I managed to achieve what I wanted to do with your help.
Another thing I needed to add is : $user->getrights(), which loads the rights of the user.