Force Email Change

Force Email Change

by John Baldassarre -
Number of replies: 3

Hello everyone.

I run a school where we upload the users via CSV. We put in fake emails for students at th beginning of the term and then have them change them manually in the profile. However, some students do not do this so when they lose their passwords, there  no way to retrieve them.

Is there a way that I can force an email address change upon first login just like I would with a password change?

Average of ratings: -
In reply to John Baldassarre

Re: Force Email Change

by Jordan Tomkinson -
There is, but it is a bit of a hack and certainly not "official" but it works.

simply blank out the email field in the database for the user, when they login next it will prompt them to change the email and not proceed until it is done.

Example sql query: update mdl_user set email = '' where username = 'student_user';

You could also do this through the mysql(phpmyadmin) contrib plugin
In reply to Jordan Tomkinson

Re: Force Email Change

by Norman Hill -
And, since you are using a fake email in the CSV upload, instead of selecting based on username, you could select on email.

Example: UPDATE mdl_user SET email='' WHERE email='fakeuser@some.domain';

As a sanity check, you could use a SELECT statement first to see if you are indeed only selecting the users you just added.


In reply to Norman Hill

Re: Force Email Change

by Omid Fatemi -

Thank you Jordan and Norman;

I did that and it worked in this way.

Whenever the user logs in, they should provide email address.

But, the problem is that even the user doesn't confirm her email address, she can continue working with the site.

Is there a way which doesn't allow the user to work until the email is confirmed?

Regards;

Omid