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

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”!

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 sub-addressing

We can use the same valid email address with sub-addressing (email+{subaddress}@domain.com), such as azmat+1@gmail.com, azmat+2@gmail.com.

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 the email requirement and remove the 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!


Stories from Moodle Dev: The Tale of the User with no Email
Eummena 24 Σεπτεμβρίου 2019
Share this post
Ετικέτες
Archive
Reflection on World Bank Group Report: Learning to Realise Education’s Potential