Skip to content

Instantly share code, notes, and snippets.

@nrackleff
Last active March 25, 2016 21:12
Show Gist options
  • Save nrackleff/26fce51b93041b078a6b to your computer and use it in GitHub Desktop.
Save nrackleff/26fce51b93041b078a6b to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_user_view_alter().
*/
function mymodule_user_view_alter(&$build) {
// Insert the contact link into the body of the display page.
if ($build['#account']->data['contact']) {
$link_text = $build['#account']->field_first_name['und'][0]['safe_value'] ? "email " . $build['#account']->field_first_name['und'][0]['safe_value'] : "email";
$contact_link = l($link_text,'user/' . $build['#account']->uid . '/contact');
$build['contact_link'][0]['#markup'] = "<div class=\"field\"><div class=\"field-label\">" . t('Contact') . ":&nbsp;</div><div class=\"field-items\"><div class=\"field-item even\">" . $contact_link . "</div></div></div>";
$build['#group_children']['contact_link'] = 'group_user_details';
}
}
/**
* Implements hook_menu_alter().
*/
function mymodule_menu_alter(&$items) {
// Remove the 'contact' tab.
$items['user/%user/contact']['type'] = MENU_CALLBACK;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment