How to remove link to personal contact form from tabs block? I created a link to personal contact form in page content, and I want to remove it from tabs. How to do that without breaking functionality?
I didn't test the following example code though, but you will be able to remove tabs using hook_menu_local_tasks_alter() in a custom module (replace mymodule by the name of your custom module):

/**
 * Implements hook_menu_local_tasks_alter().
 */
function mymodule_menu_local_tasks_alter(&amp;$data, $route_name) {
  // Whether the personal contact form tab is present. You
  // can fine-tune your conditions here. The tab route was
  // taken from ./core/modules/contact/contact.links.task.yml.
  if (isset($data['tabs'][0]['entity.user.contact_form']) {
    unset($data['tabs'][0]['entity.user.contact_form']);
  }
}


As mentioned before, I did not really try the above code. You might have to check the contents of the $data array to find the right plugin id and correct position of the tab definition when visiting a user's page.

Also note, that the tabs information will be cached. So you will have to rebuild your caches for the changes to take effect and the above hook to being triggered.

The functionality will be kept, as the route behind the tab is still active when you alter the local tasks array only.