Thanks for the module - it's a great lightweight addition!

I wasn't crazy about the idea of some users having a username of "chris_123" displayed on the site, so I themed the username output like this:

function phptemplate_username($object) {
	if ($object->name) {
		$object->name = preg_replace('/_.*$/', '', $object->name);
	}
	$output = theme_username($object);
	return $output;
}

I also didn't want the user to see the username field when editing their info, so I put this into a form_alter:

if ($form_id == 'user_edit') {
	$form['account']['name']['#type'] = 'hidden';
}

It seems like these could be good additions to the documentation (or maybe even the module itself as an option), so I thought I would mention it. Let me know if you think this might cause any problems...

Thanks again.

Comments

Christopher Herberte’s picture

your first snippet would on a large userbase cause issues when multiple users with similar names existed but the second snippet you supplied -- isn't there an option in admin/user/access to disallow edit user name. please confirm that this action is in fact what you needed.
thanks for the feedback, Chris.

xerbutter’s picture

Hi Chris, thanks for your reply.

You're right - I could have just disallowed "change own username" under access control. I forgot that I had enabled that, it was a long time ago! Thanks for pointing it out.

Regarding the first snippet, I think I see your point. There could be confusion, for example, if two different users ("joe at yahoo" and "joe at hotmail") both post comments in a forum they will both show up as posted by "joe". But, to be clear, I don't think it causes any more damage than that confusion since it's only done at the theme level.

The problem I was specifically trying to address was for when a user logs in and is greeted by "Hello [username]! Welecome to the site!" "Hello joe_123" seemed a bit confusing to me, but my solution may not be any better. I'll have to think about this some more. Maybe just using the full email address for that purpose would be better...

Best,
Xerxes

scottrigby’s picture

Hi Xerxes & Chris,

That is exactly my problem -- if username should be replaced by user-email, the login should ask for email, not username.

Ideally, I'd like the username not to show on the site at all. It would be better for me if all of the other instances of username (besides login, which should ask for email) could be replaced by the user's full-name (or at least by their email if nothing else). The instances I'm referring to include in the user edit form, registration verification email, instances of "hello, username", etc.

It seems like this is a good place to ask about that -- If so, how would I accomplish this? If not, can you suggest a better place to ask (open a separate issue)?

Thanks in advance!
Scott

scottrigby’s picture

* bump * ?

Christopher Herberte’s picture

Hi Scott, what I have assessed is that username is *absolutely* required for Drupal, core modules, developed and contributed modules and themes to function correctly. There is no way around that thus making your request particularly challenging -- partly impossible.

Firstly:
You will need to change the welcome email template as the random and temporary username data is used and obliviously not desirable. We could make the template change on installation of the module but is rather intrusive.
This should probably go in the instructions.

With Email Registration module installed and with Drupal default installation settings, login does ask for email and not username so I don't unserstand your comment there.

Full name field does not exist unless you have created it with profile.module or other. This is where it gets tricky but maybe of out of the scope of this module but I understand your requirements and providing a solution is exactly what this module was created for. I was in your shoes 12 months ago and this module was the result of the same needs.

It is a mission trying to hide the username and in the end we had to accept that. Rewriting things like authentication, node authoring and the like just is not an option.

Hope this helps you and others, maybe this makes sense and can trigger some insight into the problem and possible solutions.
Cheers, Chris.

Christopher Herberte’s picture

Also in response to #2 (Xerxes)

By default the "change own username" under access control is unchecked. This should be checked obviously if you want users to be able the change their username if they don't like the auto generated name assigned.

The possible solution for the greeting email would be to replace the !username token with !mailto and possibly mention the auto generated username in the email.

This is the way I am currently handling the task on our site http://www.joke-of-the-day.com -- maybe there is a better way.

Other suggestions anyone?

Christopher Herberte’s picture

Status: Active » Closed (fixed)

I don't think there is much that can be done here -- please feel free to reopen project issue if you think otherwise, closing this discussion.