I want to disable the user/register page in Drupal 7 but I still want registrations possible, but only through other links. I've tried altering the access to it through a module like so:

my_module_menu_alter(&$items) {
     $items['user/register']['access callback'] = FALSE;

but it does not seem to work. I know I can alter the form permission and set it to false but I need the form for other modules I have installed. Is there any way to do this with a already existing module or programmatically?

  • 1
    &items...that's not a variable...I'm surprised that even runs
    – Clive
    Commented Nov 17, 2014 at 15:47
  • The spambots will eventually find your other links, so this isn't going to be as useful as you might think. Commented Nov 17, 2014 at 19:15

2 Answers 2


Your implementation is most probably correct, I use the following code to customize access to the register page in some projects:

function MYMODULE_menu_alter(&$items) {
  $items['user/register']['access callback'] = 'MYMODULE_user_register_access';
  unset($items['user/register']['access arguments']);
  $items['user/register']['type'] = MENU_CALLBACK;

Make sure that the custom module is enabled, make sure that the module name is spelled correctly, also make sure that there really is an & prepended to the $items parameter. It happened to me in the past that I forgot the reference operator on hook_X_alter implementations. Also flush caches after adding new hook implementation functions.


Did you try doing this with configuration itself. Go to admin/config/people/accounts. Under Registration and Cancellation find out Who can register account? and set it to Administrator.


  • Don't you get it? I want people to register through another form, I don't want mo make accounts manually. This is not viable! Commented Nov 18, 2014 at 8:48
  • Another form submit handler wouldn't be affected by this configuration and still user will be able to register through it.
    – arpitr
    Commented Nov 18, 2014 at 11:07
  • 1
    If it would be entirely custom then I would agree with you. The other modules call the internal register form from Drupal. In this case it would not work. I thank for your for your feedback. Commented Nov 18, 2014 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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