Skip to content

Instantly share code, notes, and snippets.

@narodnaia
Created June 29, 2016 06:36
Show Gist options
  • Save narodnaia/db0f91b5b7927fd585b47f4de3f019b9 to your computer and use it in GitHub Desktop.
Save narodnaia/db0f91b5b7927fd585b47f4de3f019b9 to your computer and use it in GitHub Desktop.
PKP Open Journaling Systems - Database triggers to set user email as username
--
-- Create these triggers to allow OJS user login with his or her email instead of his username
-- (OJS controllers do not allow this feature, thus it can be implemented at database level)
--
DELIMITER $$
CREATE TRIGGER `update_username` BEFORE INSERT ON `users` FOR EACH ROW begin
set new.username = new.email;
end
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `update_username_edition` BEFORE UPDATE ON `users` FOR EACH ROW set new.username = new.email
$$
DELIMITER ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment