function contact_menu_local_tasks_alter
Same name in other branches
- 9 core/modules/contact/contact.module \contact_menu_local_tasks_alter()
- 8.9.x core/modules/contact/contact.module \contact_menu_local_tasks_alter()
Implements hook_menu_local_tasks_alter().
Hides the 'Contact' tab on the user profile if the user does not have an email address configured.
1 call to contact_menu_local_tasks_alter()
- ContactTest::testLocalTasksAlter in core/
modules/ contact/ tests/ src/ Unit/ ContactTest.php - Test contact_menu_local_tasks_alter doesn't throw warnings.
File
-
core/
modules/ contact/ contact.module, line 100
Code
function contact_menu_local_tasks_alter(&$data, $route_name) {
if ($route_name == 'entity.user.canonical' && isset($data['tabs'][0])) {
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']);
}
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.