RedHen Contact names appearing site-wide

Events happening in the community are now at Drupal community events on www.drupal.org.
somatics's picture

For every Contact I have (linked to a user record), their user record is showing their FirstName LastName and ContactType from their RedHen record -- sitewide wherever their user name should be displayed.

I do have the RealName module installed but that should be displaying fields from the user's profile fields.

I'm not totally opposed to this feature that RedHen seems to have introduced to our site, but...

(a) I want to know how to control it and/or disable it if I want to use RealName's settings instead; and

(b) I can't have it displaying the Contact Type along with the name -- it not only takes up too much space to ever show the name fully or gracefully anywhere, but it also shows the Contact Type (staff, vendor, etc.) which is really confusing, awkward, and inappropriate (especially when a user name is being displayed to the public, much less the user).

Can anyone tell me about this behavior and/or feature? (I can't find any reference to it anywhere.)

Comments

a few options

levelos's picture

RedHen implements hook_username_alter() to display linked users names as their RedHen full name. There are a few ways to address this.

  • Ensure that the RealName module has a lower weight than RedHen.
  • RedHen provides a hook, hook_redhen_contact_name_alter(), documented in redhen.api.php, which allows you to alter RedHen's format the full name property.
  • Implement hook_username_alter() in your own module to override RedHen's settings.

Good luck and let us know how it goes.

Lev Tsypin


ThinkShout, Inc.
thinkshout.com | twitter.com/levelos

Clarifying questions

somatics's picture

Thanks for the reply. I was hoping you could clarify:

1) Are you saying my only option to modify the formatting of the name is through altering the RedHen code or write my own module? If the answer is yes -- I am not really a code developer, so could you tell me exactly where and what I would change in the module code files?

2) How would I change the weight of RealName or RedHen -- where would this weight setting be?

Somatics, You can change the

micnap's picture

Somatics,

You can change the weight of a module either directly in your database in the system table. Change the value of the weight field for the two modules by using PHPMyAdmin or something similar.

Or you can install the util module and do it through the admin interface on your site (which is a little overkill just to be able to change weights but it will get the job done.)

Sorry I can't help you with #1 yet. It's on my to-do list. Just haven't gotten there yet.

Mickey

somatics's picture

Hi,

I was finally able to get in and do this. However, it doesn't appear to have worked:

I went to the System table and found RealName and all of the RedHen modules had the same weight -- 0 (except for redhen_registration.module, which has a weight of -1).

So, I changed the weight of RealName to -8, and cleared all caches. When I went back to a list of users, it was still showing as it did before: If there is a RedHen contact for the user, it shows their name (and the Contact type designation after the name in parenthesis) as it did before. If there is not RH contact, it shows the name from the RealName module.

So, what's wrong here? Is there something else RH is doing? Are there more than the 10 rows in the systems table for RH that might be causing this?

Thanks for your help on this.

I would really like to be

alicemoon's picture

I would really like to be able to have the drupal user names rather than the red hen contact name and type showing sitewide - as it causes some confusion for users.

There's a setting for that...

seanberto's picture

Admin > Configuration > RedHen

Check it out!
-Sean

An example of hook usage?

jhoffmcd's picture

Is there an example of hook_redhen_contact_name_alter usage? I would really like to get rid of the (conact type) to the right of the name display.

Here's what I have

micnap's picture

There is an example in the redhen.api.php file in the Redhen module.

This is what I changed mine to:

<?php

function MYMODULE_redhen_contact_name_alter(&$name, RedhenContact $contact) {
 
$name $contact->first_name . ' ' . $contact->middle_name . ' ' . $contact->last_name;
 
//dsm($contact);
}
?>

Change MYMODULE to the name of your module.
If you have the devel module installed, uncomment the dsm line to find out what items you have available to create the name from. Hope that helps.

RedHen CRM

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: