1

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?

5 Answers 5

3

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

0
2

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.

1
  • 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. Commented Feb 10, 2020 at 23:42
0

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.

2
  • 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
    Commented Jun 14, 2013 at 9:12
  • You are completely correct. I totally spaced on that! Thanks for pointing it out :-)
    – Chapabu
    Commented Jun 14, 2013 at 9:13
0

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.

0

Go to Configuration menu and account setting,

You can find Who can register accounts?

You select administator only..

That's all..

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.