I am trying to make all usernames lowercase

I am using hook_user like this when a user registers.

if($op = 'insert'){

$name = strtolower($edit['name']);
$account ->name = $name;
$edit['name'] = NULL;

}

But the drupal username in users table is still in mixed case letters.

I must be using $edit wrong or something

I have output both $account ->name and $edit['name'] after executing the above code
and $acccount ->name shows lowercase version of username
and $edit['name'] shows nothing

Please tell me where i am going wrong.

Comments

WorldFallz’s picture

Maybe try the 'submit' op?

EDIT
actually, now that I look at this again, try:

if($op = 'submit'){
  $edit['name'] = strtolower($edit['name']);
}
jabberwok’s picture

I just tried this again and it didn't work

I think that was actually the first idea I had.

WorldFallz’s picture

what about $edit['username'] = drupal_strtolower($edit['name']);

jabberwok’s picture

I put this code under submit but no it did not work

I dont think submit is getting executed on registration though

I will try your code in insert

**EDIT insert did not work either**

jabberwok’s picture

After some testing it seems that submit is not getting executed at registration

jabberwok’s picture

still need help

WorldFallz’s picture

i'm an idiot, try this:

<?php
function modulename_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'validate') {
    $edit['name'] = strtolower($edit['name']);
  }
}
?>
jabberwok’s picture

That did it!

after three days on this problem

Thank you much

mikebell_’s picture

Hi, I'm not sure whether your wanting this as a purely aesthetic thing or not. If you are then have you checked out the CSS text transform property? http://www.w3schools.com/Css/pr_text_text-transform.asp

jabberwok’s picture

I need it so as to make the email system fully work

mm167’s picture

for UTF 8 use

$string = mb_strtolower($string);

if still not ok, try mb_convert_case

jabberwok’s picture

I tried these functions and none worked

you see my problem isn't converting the string
or even overwritting $account ->name or $edit['name']
its getting drupal to save the change to the database

I am considering making a change to the db myself somehow
I just dont know when to make the change
it would get overwritten in $op == 'submit'
$op == 'login' may be the place