From this question, I tried:
$user->setAttributes(['products' => $userProductsIds]);
return Craft::$app->getElements()->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?