Home  > Blog  > 2019  > Tale user no email

Stories from Moodle Dev: The Tale of the User with no Email

24 September 2019

We are Eummena

As our technical team works on Moodle, we find ourselves tackling issues that may be of interest to other developers. As a part of the Moodle community and advocators of openness, we decided to share our own experiences from Moodle Dev, among other things of course! We’ll call these stories “Stories from Moodle Dev” and assign a playful second part to each one. For this first one, we will look at “the tale of the user with no email”!

Bottle to the sea image with text : email

[image source]

In large scale implementations of Moodle LMS, we faced an issue where some users don’t have an email address which is a required profile field in Moodle. Required fields in Moodle are “username”, “firstname”, “lastname” and “email”. Adding the user explicitly into Moodle without any required field, didn’t work, as upon log in, Moodle always redirects the user to his/her profile page prompting them to fill all required fields. Fear not, we have a solution. We actually have five of them!

1. Valid email address with incremental order

We can use same valid email address by incremental order (email+{n}@domain.com) such as azmat+1@gmail.com, azmat+2@gmail.com, Moodle will consider these email address as one valid email ‘azmat@gmail.com’, we can create multiple email address by this technique.

2. Allow user account with the same email address

By default, uploading users with duplicate email addresses is prevented. To allow duplicate email addresses, go to

Site administration > Plugins > Authentication >Manage authentication

. You can tick “Allow accounts with same email”. Then on the upload users screen you will be allowed to change the “Prevent email address duplicates” setting.

3. Profile capability changes

Another workaround for this is to prevent user permission to update profile ‘moodle/user:update’, which can be possible in some cases only but it would not be our favourite solution.

4. Hack the code

For another “not-so-recommended solution”, some changes can be done on the code to bypass email requirement and remove email option (lib/moodlelib.php:3238). The original code should be:

if (empty($user->firstname) or empty($user->lastname) or empty($user->email) or over_bounce_threshold($user)) {

Which you should replace with the following:

if (empty($user->firstname) or empty($user->lastname) or over_bounce_threshold($user)) {

5. Allow user to add dummy email

In this case when a user has no email, once they log in to the LMS the system will redirect them to the “Edit profile” page. The user can add their dummy email if they don’t have.

For this to work, the Administrator needs to uncheck Moodle settings emailchangeconfirmation. This can be accessed by Site administration > Security > Site security settings.

Well, this was our first story, straight from the adventures of our technical team! If you have any experience on the above, or a sixth solution to add, feel free to comment below! Finishing this story, we want to remind you that the suggestions we offer in such posts, are not necessarily replicable in all Moodle installations. Some of them may also not be the recommended course of action, but we’re discussing them on a theoretical level. This being said, if you do have a similar problem and you need some expert advice, reach out to us through our website or other social media, and we will be happy to help!

Story by: Azmat Ullah, Eummena

Stories from Moodle Dev: The Tale of the User with no Email

© Copyright since 2011 Eummena™

CC-BY-SA Some rights reserved.