valerio-bozzolan / LinuxDay-Torino-website

Linux Day Torino's content management system since 2016.
https://ldto.it/
GNU Affero General Public License v3.0
2 stars 5 forks source link

Save in the database the MD5 sums of the people e-mails (instead of NULL e-mails for privacy reasons) in order to display Gravatars #11

Closed valerio-bozzolan closed 5 years ago

lvps commented 5 years ago

With the power of triggers:

DROP TRIGGER IF EXISTS gravatarize;
DELIMITER $$
CREATE TRIGGER gravatarize 
AFTER UPDATE
ON ldto_user
FOR EACH ROW

BEGIN
    IF(NEW.`user_email` IS NOT NULL) THEN
        UPDATE ldto_user SET user_gravatar = MD5(NEW.user_email);
    END IF;
END $$

DELIMITER;