Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh
Category:

How to remove local tasks from login form in Drupal 8 & 9

 

You can remove Create new account local task by allow only Administrators to create accounts, so just go to Configuration > Account settings > REGISTRATION AND CANCELLATION  and check Administrators only.

 

But the other two local tasks Log in and Reset your password there is no way to hide or remove them from the UI, the only way is to use hook_menu_local_tasks_alter :

/**
 * Implements hook_menu_local_tasks_alter().
 */
function YOURMODULE_menu_local_tasks_alter(&$data, $route_name) {
  if($route_name == 'user.login'  && isset($data['tabs'][0])) {
    // Remove all tabs from user login form.
    foreach ($data['tabs'][0] as $key => $tab){
      $data['tabs'][0][$key]['#access'] = FALSE;
    }
  }
}

Clear cache and you are done! 

Comments

Add new comment

Restricted HTML

Search

Page Facebook

Become a patron

If you need some help or you search a Drupal freelancer don't hesitate to contact us.

 

Contact Us

All the content is FREE but I still need your help

 

Become a patreon