Answers.Body: <p>Can you modify, CRM/Utils/Hook.php</p>
  
  <pre><code>  public static function alterDisplayName($displayName, $contactId, $dao) {
  </code></pre>
  
  <p>and change it to</p>
  
  <pre><code>  public static function alterDisplayName(&amp;$displayName, $contactId, $dao) {
  </code></pre>
  
  <p>(note the &amp; character before the displayName argument. I suspect this will fix the issue. </p>
  
  <p>If it does, can you please file an issue and if you can create a PR to fix this issue. If not, you can reference this thread</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-19T05:13:20.657Z
Answers.Text: Thank you.  That fixed it.  I thought I was off in the weeds.  In the morning I'll figure out how to file and issue and create a PR.
Answers.UserDisplayName: Paul-Tahoe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-19T16:50:57.040Z
Answers.Text: Created issue CRM-16528 for this.
Answers.UserDisplayName: Paul-Tahoe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-20T01:50:01.017Z
Answers.Text: I think I created a PR.  Not sure if I did it right.
Answers.UserDisplayName: Paul-Tahoe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-19T03:02:12.473Z
Answers.LastActivityDate: 2015-05-19T03:02:12.473Z
Answers.UserDisplayName: Donald Lobo
Body: <p>I want to append a custom field to the display name.  To try it, I used the example.</p>
  
  <pre><code>function ccas_hooks_civicrm_contact_get_displayname(&amp;$displayname,  $contactId, $objContact) {
  $displayname = $displayname . ' - '.$contactId;}
  </code></pre>
  
  <p>No errors but what I see on the View Contact form doesn't change.</p>
  
  <p>I added a watchdog thing after it</p>
  
  <pre><code>watchdog('hooks',"callhooks_civicrm_get_(&amp;\$fields, &amp;\$files, &amp;\$form)&lt;pre&gt;\n\$display_name=" . var_export($displayname,1) . "\n\$contactId=" . var_export($contactId,1) . "\n\$objContact=" . var_export($objContact,1) . '&lt;/pre&gt;');
  </code></pre>
  
  <p>In the log I can see it appending the contact id after the display name but still it only shows the name.  So do I need to do something additionally to actually get it to show it on the form?</p>
  
  <p>Currently using 4.5.5.</p>
  
Tags: <hooks>
Title: Can't get hook_civicrm_contact_get_displayname to work
ThreadText: # Can't get hook_civicrm_contact_get_displayname to work
  
  (Asked by: username_0 on 2015-05-19)
  
  I want to append a custom field to the display name. To try it, I used the example.
  
  ```
  function ccas_hooks_civicrm_contact_get_displayname(&$displayname,  $contactId, $objContact) {
  $displayname = $displayname . ' - '.$contactId;}
  
  ```
  
  No errors but what I see on the View Contact form doesn't change.
  
  I added a watchdog thing after it
  
  ```
  watchdog('hooks',"callhooks_civicrm_get_(&\$fields, &\$files, &\$form)<pre>\n\$display_name=" . var_export($displayname,1) . "\n\$contactId=" . var_export($contactId,1) . "\n\$objContact=" . var_export($objContact,1) . '</pre>');
  
  ```
  
  In the log I can see it appending the contact id after the display name but still it only shows the name. So do I need to do something additionally to actually get it to show it on the form?
  
  Currently using 4.5.5.
  
  **Tags:** hooks
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-05-19. Score: 2 | Accepted answer
  
  Can you modify, CRM/Utils/Hook.php
  
  ```
    public static function alterDisplayName($displayName, $contactId, $dao) {
  
  ```
  
  and change it to
  
  ```
    public static function alterDisplayName(&$displayName, $contactId, $dao) {
  
  ```
  
  (note the & character before the displayName argument. I suspect this will fix the issue.
  
  If it does, can you please file an issue and if you can create a PR to fix this issue. If not, you can reference this thread
  
  > **Comments:**
  > **username_0**: Thank you.  That fixed it.  I thought I was off in the weeds.  In the morning I'll figure out how to file and issue and create a PR.  
  > **username_0**: Created issue CRM-16528 for this.  
  > **username_0**: I think I created a PR.  Not sure if I did it right.  
  
  ---
  
  