Project:Email Registration
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Would it make sense to use the UID as the username instead of the email address? Just a thought.

Comments

#1

This would be a great new feature! Having option to use UID or UID as 7 digit number etc; ie 0000001, 0000002, 0000003...

#2

I've only used the D6 version, but here is the way to do it with this version. (In a custom module)

<?php

/**
* Implementation of hook_email_registration_name();
*
*  Generates a user name based on the user uid of the
*  new user.
*/
function HOOK_email_registration_name($edit, $account) {
 
// sprintf pads the number to a length of 7 characters
  // e.g. uid = 25 becomes 0000025
 
return 'Add a prefix here'. sprintf('%07s', $account->uid) .'or a suffix';
}

?>

If this works in Drupal 5, change the component of this issue to "Documentation" and status to "Needs work"

:)

#3

Hello Alan D.
I also use D6 - if I activate a custom module with the above code now, but already have members on my site, will the current user's usernames change as well? If not, how can I get all current and new users to go with the username=uid rule?
Thanks for your help.

#4

you would need to add an update script or do a manual sql query.

In the file HOOK.install (HOOK for module name)

Never run and is not been tested!!!!

<?php

function HOOK_update_6000() {
 
$ret = array();
 
// Notice that the uid > 1 prevents this from changing the admin username
 
$q = db_query("SELECT uid, name FROM {users} WHERE uid > 1");
  while (
$account = db_fetch_object($q)) {
   
$name = HOOK_email_registration_name(array(), $account);
   
db_query("UPDATE {users} SET name = '%s' WHERE uid = %d", $name, $account->uid);
  }
  return
$ret;
}


?>

Two other issues found:

  1. The early emails will also have the wrong user name too.
  2. The path alias is also generated incorrectly using the old name.

#5

Version:5.x-2.1» 6.x-1.x-dev

can someone please help to make this feature work in the latest D6 dev?
thanks!

#6

kindly bumping to be considered as a new feature in Email Registration where options for the username can be pre-determined.

nobody click here