MyBB Community Forums

Full Version: Force DB field to uppercase
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok, my issue was that the usernames in the DB needed to be only UPPERCASE. 
The solution was to add a trigger to my mysql database.

Connect to the mysql database with correct access:
mysql -u root -p

Select the DB, in my case mybb
use mybb;

Then add the trigger for the username:
CREATE TRIGGER forceupper BEFORE INSERT ON mybb_users FOR EACH ROW SET NEW.username = UPPER(NEW.username);

In case of a mistake, remove the trigger:
DROP TRIGGER forceupper;
WHY must your usernames be uppercase in the database? Is it for integration with another system (eg. Mediawiki requires wiki-case)? The MyBB login code is case-insensitive.

Why not create a plugin which uses the datahandler_user_insert and datahandler_user_update hooks? You may want to see which other hooks are available in the UserDataHandler class ( inc/datahandlers/user.php).