Print error message returned by before_alternc_add_member hook

This commit is contained in:
Nina 2023-06-01 03:34:56 -04:00 committed by Camille Lafitte
parent 0b5725cb86
commit fa8e4a71e0
1 changed files with 6 additions and 5 deletions

View File

@ -639,13 +639,14 @@ class m_admin {
return false;
}
// Additional checks before a user is created
// Do not create the account if any hook returned false
// Do not create the account if any hook has a return value
// The returned value should provide additional information
$before_add_hook_data = $hooks->invoke('hook_before_alternc_add_member', [$login]);
foreach($before_add_hook_data as $create) {
if(!$create) {
$msg->raise("ERROR", "admin", _("-- I cannot create this account --"));
return false;
}
if($create !== null) {
$msg->raise("ERROR", "admin", _("The account '%s' cannot be created. %s"), [$login, $create]);
return false;
}
}
$pass = password_hash($pass, PASSWORD_BCRYPT);