Skip to content

Commit 41b1c16

Browse files
committed
Add config "send_notification_when_user_added" see BT#13430
Send message to admin depending the configuration when a new user is created and email is sent to the user.
1 parent 4662d4d commit 41b1c16

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

main/inc/lib/usermanager.lib.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ public static function create_user(
485485

486486
$layoutContent = $tplContent->get_template('mail/content_registration_platform.tpl');
487487
$emailBody = $tplContent->fetch($layoutContent);
488+
488489
/* MANAGE EVENT WITH MAIL */
489490
if (EventsMail::check_if_using_class('user_registration')) {
490491
$values["about_user"] = $return;
@@ -514,6 +515,15 @@ public static function create_user(
514515
null,
515516
$additionalParameters
516517
);
518+
519+
520+
$notification = api_get_configuration_value(' send_notification_when_user_added');
521+
if (!empty($notification) && isset($notification['admins']) && is_array($notification['admins'])) {
522+
foreach ($notification['admins'] as $adminId) {
523+
$emailSubject .= get_lang('UserAdded').': '.api_get_person_name($firstName, $lastName);
524+
MessageManager::send_message_simple($adminId, $emailSubject, $emailBody);
525+
}
526+
}
517527
}
518528

519529
if ($sendEmailToAllAdmins) {

main/install/configuration.dist.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,3 +646,5 @@
646646
// Allow multiple anon users see BT#13324
647647
//$_configuration['max_anonymous_users'] = 0;
648648

649+
// Send email notification to admin when a user is created
650+
//$_configuration['send_notification_when_user_added'] = ['admins' => 1 ];

0 commit comments

Comments
 (0)