contact_menu_local_tasks_alter(&$data, $route_name)
Implements hook_menu_local_tasks_alter().
Hides the 'Contact' tab on the user profile if the user does not have an email address configured.
function contact_menu_local_tasks_alter(&$data, $route_name) { if ($route_name == 'entity.user.canonical') { foreach ($data['tabs'][0] as $href => $tab_data) { if ($href == 'entity.user.contact_form') { $link_params = $tab_data['#link']['url']->getRouteParameters(); $account = User::load($link_params['user']); if (!$account->getEmail()) { unset($data['tabs'][0]['entity.user.contact_form']); } } } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!contact!contact.module/function/contact_menu_local_tasks_alter/8.1.x