0

There Drupal links, such as sitename.com/?q=user or sitename.com/?q=user/register that a user may use for direct login or registration to my site.

What I want to do is to disable those types of direct links. I have placed my custom blocks for login and sign up in the first page, so if a user hits the URLs above, a strange view of mysite is displayed because it has 2 registration forms: One exists because of my custom block and another exists because Drupal's default registration form

Does anyone know how could I disable or remove all the links of type sitename.com/link and the only link that can direct to mysite to be sitename.com? I know that seems hard because it maybe is not configured in Drupal's layer, but on HTTP protocol. So if that is not possible, can you think of any solution to avoid the above mess?

2

There is two options using a custom module:

  1. Disable access to this path using hook_menu_alter()

    function MYMODULE_menu_alter(&$items) {
      unset($items['user/register']);
    }
    

    This option will send the user to an access denied page.

  2. Redirect the user to the home page (or another one)

    function MYMODULE_module_menu_alter(&$items) {
      $items['user/register']['page callback'] = 'MYMODULE_go_home';
    }
    function MYMODULE_go_home() {
      drupal_goto('/');
    }
    

    Inspiration: Disabling /node view and other hidden views in Drupal?

PS: I'm not sure why you want to remove /user ? For this special path you can also use hook_user_view().

0

You can just use the Redirect module and redirect /user and /user/register to the frontpage. This module allows you to specify a redirect from one path to another path or an external URL, using any HTTP redirect status.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.