provide a hook so other modules can help generate the user name

mdowsett - April 17, 2008 - 03:35
Project:Email Registration
Version:6.x-1.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I don't like the way this module generates the user's username. I'd like it to be generated from the profile first and last names as set up in the user registration form.

I mainly want this as the confirmation email users get have a garbled system-generated user name that they find confusing....even tho their user name is actually their pre-@ part of their email address.

I tried using this module along with the auto_username module but it seems that this module still wins the battle in generating the user name.

I like how auto_username allows you to define how you want to name the username by seeing all profile fields in the admin settings. I'd even be happy if this module can be altered in the code to generate the user name by manually entering in the profile field names.

#1

Nithaiah - February 6, 2009 - 11:13
Version:5.x-2.1» 6.x-1.1

subscribe

#2

Chris Herberte - February 9, 2009 - 00:04

I'm starting a new project which requires this type of functionality, email_registration will get some lovin' in this department over the next few weeks. Expect new release soon, need testers.

#3

mdowsett - February 18, 2009 - 00:56

I was also just recently pointed to the Realname module but it isn't really suiting my needs (there seems to be some issues).

I look forward to your updates!

#4

Chris Herberte - February 22, 2009 - 20:25
Version:6.x-1.1» 6.x-1.x-dev

#5

asak - February 14, 2009 - 14:10

Just downloaded the latest dev release (from 1 hour after your post) - but i can't seem to find the content_profile and token support mentioned.

In the module file, I see this:

/**
* function email_registration_settings() {
*  return system_settings_form($form);
* }
*/

And no instance of content_profile anywhere in the code, just:
if (module_exists('profile') && is_array($form['account'])) {

..Do i have the right version? This is a great module which fits perfectly for a current project, i'll gladly help test this out.

#6

asak - February 23, 2009 - 17:21

Still can't get this working...

Users are getting in their emails a strange username - but on the admin pages i see the correct pre-@ usernames.

Solvable...?

#7

mikeryan - April 2, 2009 - 20:00
Status:active» needs review

The attached patch provides hook_email_registration_name($edit, $account) - by implementing this hook in a module, you can replace email_registration's default username generation with whatever you like. This operates on a case-by-case basis - in my case, I'm migrating to Drupal from a system which used email for logging in, but also had usernames - only for users who had commented. So, with this implementation, I can return the existing username when it exists, and otherwise return NULL and allow email_registration to generate a username for the rest.

Comments?

AttachmentSize
email_registration.module.patch 3.01 KB

#8

Chris Herberte - April 2, 2009 - 21:50

Mike, I love the idea. Patch failed?

#9

mikeryan - April 2, 2009 - 21:58

Hmm, try this one...

AttachmentSize
email_registration.module.patch 2.78 KB

#10

Chris Herberte - April 2, 2009 - 22:49

Still she no go. I'll apply the changes manually and commit it when I get a minute

#11

andypost - April 14, 2009 - 14:21

Suppose there's not clear solution so let's go to Hall of Shame

#12

greggles - June 10, 2009 - 12:22
Title:other formats to generated user name» provide a hook so other modules can help generate the user name
Status:needs review» fixed

Thanks mikeryan, Chris.

I've now committed this to the 6.x branch: http://drupal.org/cvs?commit=223514

@andypost - I don't understand why you would post that message in this thread. I like the so called "hall of shame" but this module's existence there is not for shame - it doesn't duplicate functionality - and this issue has nothing to do with duplication (aside from the misplaced messages by asak). Poor form, sir.

#13

System Message - June 24, 2009 - 12:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#14

aschiwi - July 30, 2009 - 07:53
Status:closed» active

So how exactly does this work now?

The auto_username module only has a 5.x release. I have also been running realname module which changes the display of the username to whatever profile fields you choose, but the actual username stays the same.

#15

greggles - August 17, 2009 - 18:44
Status:active» closed

This is a hook and you have to write code to implement that hook to get it to work. The hook is:

<?php
module_invoke_all
('email_registration_name', $edit, $account);
?>

So your code would have to be something like:

<?php
function mymodule_email_registration_name($edit, $account) {
  return
md5($account->mail);
}
?>

 
 

Drupal is a registered trademark of Dries Buytaert.