Hide the "Create a new account" tab when lacking a registration code

zostay - May 4, 2007 - 22:09
Project:Invite
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

When the site is set to allow new accounts by invitation only, the Create new account tab shows up if a user clicks on the Request a New Password link.

It would be nice to remove the Create a new account tab unless they hit the page directly. It's kind of confusing to some folks and I'd rather not waste my time on this kind of support. ;)

I don't know how possible this actually is (I'll look into it and submit a patch if I can), but we may be resorting to just using CSS to hide it that way if nothing else.

#1

knseibert - May 7, 2007 - 21:47

Hi Andrew,
the problem is that the menu entry is generated in the user.module whenever variable_get('user_register') returns not 0 (aka whenever User settings->Public registrations is not set to "Only site administrators..."). There is no way around that without patching the user.module. So i guess the invite.module cannot solve your issue.
However you could add the following lines to your template.php file(s):

function phptemplate_menu_item_link($item, $link_item) {
  if ($item['title'] == t('Create new account') && $item['path'] == 'user/register') return;
  return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
}

This prevents the "Create new account" menu item from being rendered.

#2

zostay - May 15, 2007 - 20:17

Thanks!

I'll try the work-around.

#3

patchak - June 2, 2007 - 00:34

This workaround worked, thanks a lot!

#4

smk-ka - June 8, 2007 - 17:27
Status:active» fixed

Added knseibert's snippet to the (slightly outdated *ahem*) README.txt.
--
Stefan Kudwien
unleashed mind

#5

Anonymous - June 22, 2007 - 17:27
Status:fixed» closed

#6

jechilt - March 10, 2009 - 03:17
Version:5.x-1.7» 6.x-2.x-dev

I need this to work in version 6.x

can someone help me?

 
 

Drupal is a registered trademark of Dries Buytaert.