diff --git a/user/externallib.php b/user/externallib.php index f03b9b858a9..803fce52414 100644 --- a/user/externallib.php +++ b/user/externallib.php @@ -180,7 +180,8 @@ class core_user_external extends external_api { // Make sure we validate current user info as handled by current GUI. See user/editadvanced_form.php func validation(). if (!validate_email($user['email'])) { throw new invalid_parameter_exception('Email address is invalid: '.$user['email']); - } else if ($DB->record_exists('user', array('email' => $user['email'], 'mnethostid' => $user['mnethostid']))) { + } else if (empty($CFG->allowaccountssameemail) && + $DB->record_exists('user', array('email' => $user['email'], 'mnethostid' => $user['mnethostid']))) { throw new invalid_parameter_exception('Email address already exists: '.$user['email']); } // End of user info validation.