Commit 7c96762d authored by Richard Mansfield's avatar Richard Mansfield Committed by Nigel McNie
Browse files

Don't die when failing to send new user a welcome email

parent 1c70c15f
......@@ -197,7 +197,7 @@ function adduser_submit(Pieform $form, $values) {
$user->quota = $values['quota'];
$user->passwordchange = 1;
global $USER;
global $USER, $SESSION;
if ($USER->get('admin')) { // Not editable by institutional admins
$user->staff = (int) ($values['staff'] == 'on');
$user->admin = (int) ($values['admin'] == 'on');
......@@ -243,10 +243,15 @@ function adduser_submit(Pieform $form, $values) {
handle_event('createuser', $user);
db_commit();
email_user($user, $USER, get_string('accountcreated'),
get_string('accountcreatedchangepasswordtext', 'mahara', $user->firstname, get_config('sitename'), $user->username, $user->password, get_config('sitename')),
get_string('accountcreatedchangepasswordhtml', 'mahara', $user->firstname, get_config('sitename'), $user->username, $user->password, get_config('sitename'))
);
try {
email_user($user, $USER, get_string('accountcreated'),
get_string('accountcreatedchangepasswordtext', 'mahara', $user->firstname, get_config('sitename'), $user->username, $user->password, get_config('sitename')),
get_string('accountcreatedchangepasswordhtml', 'mahara', $user->firstname, get_config('sitename'), $user->username, $user->password, get_config('sitename'))
);
}
catch (EmailException $e) {
$SESSION->add_error_msg(get_string('newuseremailnotsent', 'admin'));
}
redirect('/admin/users/edit.php?id='.$id);
}
......
......@@ -304,6 +304,7 @@ $string['adduser'] = 'Add User';
$string['adduserdescription'] = 'Create a new user';
$string['adduserpagedescription'] = '<p>Here you may add a new user to the system. Once added, they will be sent an e-mail informing them of their new account, including their username and password. They will be asked to change their password upon first log in.</p>';
$string['createuser'] = 'Create User';
$string['newuseremailnotsent'] = 'Failed to send welcome email to new user.';
// Login as
$string['loginasuser'] = 'Login as %s';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment