When I use the sample rule Eileen posted on CiviCRM.org blog post for creating a Drupal user account automatically when a Tag is selected, it fails for Organizations with more than one space in the name e.g. "A Sample Organization Record". A drupal error is thrown about usernames only being allowed to have one space. Perhaps the code was only meant for individuals, first + last ? Is there a way to make it suitable for Organizations too?

If its automatically creating the username, perhaps it could just take the first two words from the Organization Name field, or it could just use the first part of the email address, or the email account itself as the login name?

Comments

zkrebs’s picture

Issue summary: View changes
zkrebs’s picture

Issue summary: View changes
commonpike’s picture

StatusFileSize
new12.07 KB
new5.58 KB

The same error occurs for accounts created by normal contacts, if there is a space in either their first or last name (eg, if the first name accidently ends in a surplus space). This happened to me on a drupal signup webform that uses rules to create both a contact with membership and a drupal login.

If I look here
http://cgit.drupalcode.org/civicrm_entity/tree/civicrm_entity.module

This method
civicrm_entity_action_create_user

just uses $contact['display_name'] without sanity checks.

It's debatable, but this particular trigger would most likely mess up any workflow depending on it if it would fail.
I would rather it created a user with a serial number as a name, and throw a warning, when it fails. But perhaps that is a different issue.

markusa’s picture

Priority: Major » Normal

Ok, so community how should we handle names with more than one space? Can we come to a consensus as to what the username should be by default in this case?

email address as username?
Just remove the spaces and concatenate the name(s)?

cid as username?

zkrebs’s picture

markusa; would there be any way to 'tokenize' this or leave it user configurable somehow?

markusa’s picture

Assigned: Unassigned » markusa
Category: Bug report » Feature request

yeah that makes sense.

We should allow whoever is a choice in what becomes the username.

So there's that issue, and then what to do when the display_name is chosen, but has multiple spaces.

In that case i think its replacing the space, with a configuration character, e.g. '-', or '_',

markusa’s picture

Status: Active » Fixed

So there is now a configuration field when creating a user, to choose whether the user name is
'first last'
'firstlast'
'first.last
or the email address.

The issue with the spaces has been resolved as well.

Please install the newly released 2.0-beta5 and try it out, if its still an issue we'll reopen the task.

Status: Fixed » Closed (fixed)

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