Is there a way to send errors back to the set password form?
I am listening to the users.onBeforeSetPassword
event in which I want to confirm that the string in a confirm password field is the same as in the newPassword field.
craft()->on('users.onBeforeSetPassword', function(Event $event) {
// Only do anything if it is a front end submission
if(craft()->request->isSiteRequest())
{
$newPassword = craft()->request->getPost('newPassword');
$passwordConfirm = craft()->request->getPost('passwordConfirm');
if(isset($passwordConfirm) && strcmp($newPassword, $passwordConfirm) !== 0)
{
$event->params['user']->addErrors(array('newPassword' => Craft::t('Passwords do not match')));
$event->performAction = false;
}
}
});
}
}
This does prevent the user from resetting their password but doesn't send a error message back to the template. How can I pass a variable back to the template so I can show the user their error?
performAction
and include the html by yourself. You just have to append an unsorted list with the message. – Robin Schambach Oct 24 '17 at 5:50