开发者

How do I remove the user registration/login form?

My we开发者_如何学Pythonbsite doesn't need the user login functionality. Only some users need to post new nodes.

How do I remove the user registration and the login forms in Drupal?


While it's technically possible to remove the login functionality, you shouldn't, because then your administrator could never log onto the site.

In order to remove the register functionality, you simply need to browse to admin/user/settings (for Drupal 6) or admin/config/people/accounts (for Drupal 7) and select the the "Only site administrators can create new user accounts" option.


While jhedstrom answer does work, I particuarly find that it doesn't fully address the issue.

Here's a simple way to remove the login form from the site on Drupal 7.

First, let's create a new simple page called Admin. Simply go to Content - Add Content - Basic Page. Enter whatever details you'd like such as title, body, etc. just make sure that under URL path settings you specify a common alias for adminstration, I used admin.

Second step, let's make sure that the login form only shows on the admin page we just created. Navigate to Structure - Blocks - User login (note tat the block name may vary from installation to installation), and hit Configure. Under Visibility settings select the option Only the listed pages so that the block only shows for the pages you specify on the input, and enter the alias you set on the step above (admin).

Finally, let's ensure that only administrators can create accounts, by following jhedstrom's suggestion. Go to Configuration - People - Account settings, then under Registration and cancellation, ensure that the box for Administrators Only is selected for the Who can register accounts? option.

I think this is a much nicer and detailed approach to ensure that the login form isn't displayed, considering you don't need people creating accounts on your site.


You can override it using hook_menu(), move login page in any other suitable for administrative needs place


You can disable the forms all together. In a custom module:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
    case 'user_login':
    case 'user_register_form':
      $form['#access'] = FALSE;
    break;
  }
}

Depending on your needs, you can either create a custom page and set the login block there, so you and other administrators can login, or install HybridAuth module to allow visitors to login and register new accounts only through social media 3rd parties.


You can use the Disable Login Page module to disable the login page completely for the general public. Only the webmaster or site admins who have access to a secret key/value pair will be able to access the login page. Everybody else will get access denied at user/login page. This will work in Drupal 8 and Drupal 9.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜