I'm attempting to allow a user to edit other users via a front-end form. The "Edit users" permission has been checked in the admin but when I submit the form the data doesn't save. For this example, I'd prefer not to use hidden inputs within the form to manipulate the data.
Event::on(
User::class,
User::EVENT_BEFORE_SAVE,
function (ModelEvent $event) {
//User id is the id of another user, not the sender.
$userId = $this->request->getBodyParam('userId');
$user = Craft::$app->users->getUserById($userId);
$fieldName = 'exampleTextField';
$user->setFieldValue($fieldName, 'I want this text to populate exampleTextField');
});