Set User's entry field from PHP in Craft 3 From this question, I tried:

$user-&gt;setAttributes(['products' =&gt; $userProductsIds]);

return Craft::$app-&gt;getElements()-&gt;saveElement($user);


Where $user is an instance of craft\elements\User; and $userProductsIds an array. It's not giving me any errors, but the user is not updated. Any idea on what am I missing?
By checking vendor/craftcms/cms/src/controllers/UsersController.php and vendor/craftcms/cms/src/base/Element.php, I did it like 

$user-&gt;setFieldValue('products', $userProductsIds);
return Craft::$app-&gt;getElements()-&gt;saveElement($user, false);