You should just reference the field as an object property of the user instead of using setFieldValue
. I also use the getElements function instead of using the property, but I don't think that makes much difference. The code below should work.
public function actionUpdateuser() {
// Update user data
$userId = 67852;
$user = Craft::$app->users->getUserById($userId);
$user->userCompanyName = 'New Name 2';
$result = Craft::$app->getElements()->saveElement($user);
return $result;
}
Also make sure to add the Craft Users class at the top of the page with:
use craft\elements\User;