A previous developer repurposed the "formal title" field to be used as "badge name" for events.

The problem is that when viewing a contact, it doesn't show there unless you go to edit the name.

I found a "recipe" for displaying formal title as part of the general display of names, but that is not what we want.

How can we 1. display the "formal title" field when viewing a contact, but 2. not display it as part of a name everywhere that a name is displayed?

  • Have a look at the screenshot here: gist.github.com/mecachisenros/785d9d8eef15359b4f66a332406b7b0e that appends an id to the contact name in the Contact Summary but you can append pretty much anything and is a fairly easy customization, I'm just wondering if something like that would work for you, if it does I'll add an answer with instructions.
    – Andrei
    Commented Apr 8, 2016 at 19:25
  • Something like that could work - we may have to use some conditionals to show it only in certain places, mainly when viewing a contact as admin
    – GHolmes
    Commented Apr 8, 2016 at 20:37

2 Answers 2


As @coleman says and as I also mentioned in my comment above, you can create an extension as explained here or you can use an existing one and implement hook_civicrm_contact_get_displayname, somthing like this:

function myextension_civicrm_contact_get_displayname(&$display_name, $contactId, $objContact) {
    $formal_title = civicrm_api3('Contact', 'getsingle', array(
        'sequential' => 1,
        'contact_id' => $contactId,
        'return' => 'formal_title',
    if(!$formal_title['is_error'] && !empty($formal_title['formal_title'])){
        $display_name = $display_name . ' - Formal Title: ' . $formal_title['formal_title'];
    } else {
        $display_name = $display_name;

I think what you want is hook_civicrm_contact_get_displayname. This allows you to alter the display name of a contact when it appears in the UI (namely in the contact summary screen and a few other screens where the display name is used as a title) without changing it in the db.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.