I have 2 roles on my site. I created 2 pages and corresponding links through which each of the roles will register.

I want to prevent users from using the default user registration menu ("create new account") by either deleting it or hiding it. Also i want to prevent users from being able to visit user/register.

Please how can i achieve this?


Use hook_menu_alter() to remove default registration page from menu system. Simply unset($items['user/register']); and clear menu cache.

| improve this answer | |

I think, there is no need to use hooks or any module for it.

Follow below steps:
1) Go to Account settings(admin/config/people/accounts)
2) Under REGISTRATION AND CANCELLATION > Who can register accounts
3) select Administrators only
4) Save configuration
5) Go and check

However, I would like to have feedback from community if I am missing some use-case here where its must to use module/hook.

| improve this answer | |
  • I'd say yours is generally the simplest solution, but it sounds like the OP wants to allow anonymous users to register, just not from the user/register page. So in that case, hook_menu_alter is what's needed. – Kelley Curry Feb 10 at 23:42

The easiest option is to use Tab Tamer to hide any tabs you don't want.

Tab Tamer is an administration utility that provides easy re-ordering, hiding, and deactivation of tabs and subtabs. You can also rename tab labels.

Then use hook_menu_alter() to either disable the path, or redirect any requests to another page.

| improve this answer | |
  • If he'll disable path via hook, why would he need a Tab Tamer at all? As far as I know tab would disappear anyway if path is removed. – Mołot Jun 14 '13 at 9:12
  • You are completely correct. I totally spaced on that! Thanks for pointing it out :-) – Chapabu Jun 14 '13 at 9:13

You can add path alias in Pathauto (admin/config/search/path/add) ;)

Existing system path: any/page
Path alias: user/register

This is simplest solution, but has one disadvantage: the url in the browser is still user/register despite the fact that user is on other page.

| improve this answer | |

Go to Configuration menu and account setting,

You can find Who can register accounts?

You select administator only..

That's all..

| improve this answer | |

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.