Hello,

I'm attempting to use the feature "Create a contact during user registration" and it seems to work fine with one exception, The system ignores my Contact Type definition - Both the default and if I enter it into the URL.

The contact does get created but the Contact Type for the new person is blank in the list of contacts. In the database, the member type is shown as 'create' which isn't a defined contact type in my website.

Many Thanks.

Comments

ttrichell’s picture

I ran into the same issue. I'm running Drupal 7.24 and I'm new to Drupal so bear that in mind.

I think I may have found the hang-up when trying to create the contact during Drupal user creation. In the 7.x-1.6 version of redhen_contact.module's 'redhen_contact_form_user_register_form_alter' (line 907) function the 'if (isset($menu_item['original_map'][2])) {' statement is grabbing the 3rd argument which is set to "create" when adding a Drupal user.

I'm not sure if this is a change in Drupal core with the update, but here is the change that fixed it for me and I'd have created a patch if I had more time to figure that out.

Change the code to look for the fourth argument:

    if (isset($menu_item['original_map'][3])) {
      $contact_type = $menu_item['original_map'][3];

I hope this helps in some way, I'm sure it will need to be re-worked to be backwards compatible if it is indeed a core change, but I have a deadline and needed it working for my situation ASAP.

Thanks!

karlnack’s picture

There are a couple issues causing this:

  1. The new user registration form is accessed through (at least) two urls: user/registration (for anonymous registration) and admin/people/create (when an administrator adds a new user). Consequently the user-added URL path component to override the default contact type isn't always correctly parsed: as noted in comment #1, the current implementation assumes it's always in the 3rd position, when actually it could vary.
  2. The user-added URL path component is not validated, so the module attempts to create a contact using whatever is entered, which will result in a contact with no type if an invalid contact type is entered.

Unless I'm misunderstanding the use case for this, it seems to me that a solution other than having the user manually alter the registration url would be desirable. Consequently I've attached a patch that eliminates the ability to override the default contact type during new user registration. Even if this isn't the final solution, it at least ensures in the interim that a contact of a valid type is always created during new user registration.

Thanks.

chalee’s picture

In my case the contact created from new user registration has no data in all the fields. I tried the patch above but it didn't work.

karlnack’s picture

chalee, you need to ensure "Update contact fields" is checked in the RedHen configuration settings (admin/config/redhen/crm). That's unrelated but also problematic behavior.

chalee’s picture

Thanks Karlnack. I had not seen that setting.

levelos’s picture

Status: Active » Fixed

Good catch, thanks everyone. I took a slightly different approach in 50040a7310f95c337041e15a12e53820f63f99d5 which I think takes care of the problem while still maintaining the flexibility.

Status: Fixed » Closed (fixed)

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

  • Commit 50040a7 on 7.x-1.x, redhen-donation by levelos:
    #2126717 by levelos: Only allow contact type to overridden during user...

  • Commit 50040a7 on 7.x-1.x, redhen-donation, relation-roles by levelos:
    #2126717 by levelos: Only allow contact type to overridden during user...