MyBB Community Forums

Full Version: How to force usernames to UPPERCASE
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
For my application, I would like the usernames people register with to be forced to capitals.

Any help? Huh
you need to edit the registration form and add a custom class for username, right now it is

input.textbox

GLOBAL CSS
input.textbox {
background: #fff;
color: #333;
border: 1px solid #ccc;
padding: 3px;
outline: 0;
font-family: "Open Sans",sans-serif;
font-size: 14px;
}


JUST ADD THIS TO THE NEW CSS
text-transform: uppercase;

TESTED AND WORKED, let me know if you need any more help
(11-26-2018, 05:19 PM)lisa Wrote: [ -> ]For my application, I would like the usernames people register with to be forced to capitals.

Any help? Huh

https://community.mybb.com/mods.php?action=view&pid=350 Strict Username
(11-26-2018, 06:17 PM)Michael2014 Wrote: [ -> ]you need to edit the registration form and add a custom class for username, right now it is

input.textbox

GLOBAL CSS
input.textbox {
   background: #fff;
   color: #333;
   border: 1px solid #ccc;
   padding: 3px;
   outline: 0;
   font-family: "Open Sans",sans-serif;
   font-size: 14px;
}


JUST ADD THIS TO THE NEW CSS
text-transform: uppercase;

TESTED AND WORKED, let me know if you need any more help
Ok, I created a uppercase.css file by copying global.css.

See screenshot.  I added the above line to it.

Now... since I'm really new to this... I understand I need to find and edit the registration page and tell it to use this new uppercase.css for the style on username?
I think that would force the user to use uppercase, I don't want that, but I do want whatever they type to be converted into uppercase when they save the form.
(11-26-2018, 09:41 PM)lisa Wrote: [ -> ]I think that would force the user to use uppercase, I don't want that, but I do want whatever they type to be converted into uppercase when they save the form.

I guess I am confused on the need as the input would input it as Uppercase thus forcing the data inputted to uppercase then in theory saving to database as uppercase because it is inputted on registration as such thus negating any lowercase they may have used that was then transformed, would it then not be primarily the same as using aforementioned plugin to force registration username to uppercase only?
add this to the uppercase css file, this should be the only thing in the uppercase css file, nothing else.


input.textbox-uppercase {
   background: #fff;
   color: #333;
   border: 1px solid #ccc;
   padding: 3px;
   outline: 0;
   font-family: "Open Sans",sans-serif;
   font-size: 14px;
text-transform: uppercase;
}

okay that is step one. Step two is opening the template Member >> Member_register

in this template, look for something like this


<td colspan="2"><input type="text" class="textbox" name="username" id="username" style="width: 100%" value="{$username}" /></td>


and change the class="textbox" to class="textbox-uppercase"

and that is all but the flaw to this is, if users can change their name then you would have to change the class in the change username form as as well. but that would only take a second to do, let me know if you need any more help.
That's great! I only have one question: What is the location that the uppercase.css file should be in? I searched for css files, and found them all over, the place I chose was ./cache/themes/theme1/uppercase.css

But that didn't work, I then thought maybe I was using the wrong template, so I made that change to both the default and NewDefault. But when I type in the username field of the registration screen, it's still not uppercase...

I got it!! Thank you!

I had to make the changes in the NewDefault template...
There's a problem Houston!!! The registration form does show uppercase when you enter it, but the username still gets put in lowercase when it goes into the database...

So it looks like this change ONLY effects what you see, not reality... I'm looking for a new solution.....

CREATE TRIGGER forceupper BEFORE INSERT ON mybb_users FOR EACH ROW SET NEW.username = UPPER(NEW.username);

Problem solved!!
Even if the user enters a username with lowercase letters, the mysql trigger will change it to uppercase. Exactly what I want.

CREATE TRIGGER forceupper BEFORE INSERT ON mybb_users FOR EACH ROW SET NEW.username = UPPER(NEW.username);
Pages: 1 2