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.

Comments

knseibert’s picture

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.

zostay’s picture

Thanks!

I'll try the work-around.

patchak’s picture

This workaround worked, thanks a lot!

smk-ka’s picture

Status: Active » Fixed

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

Anonymous’s picture

Status: Fixed » Closed (fixed)
jechilt’s picture

Version: 5.x-1.7 » 6.x-2.x-dev

I need this to work in version 6.x

can someone help me?

studiopow’s picture

Version: 6.x-2.x-dev » 6.x-2.0-alpha1
Status: Closed (fixed) » Active

Hi, I tried the code snippet found here to remove the rendering of the "Create new account" tab as described above but I get the following message: warning: Missing argument 2 for phptemplate_menu_item_link() in (...)template.php on line 209. How could that be fixed or did I miss something essential?

synesthete’s picture

The snippet from knseibert is written for the 5 version of theme_menu_item_link. The 6 version has only $link as an argument.

function YOURTHEMENAME_menu_item_link($link) {
  // Do not render tab or link for "Create new account" pointing to "user/register".
  if ($link['title'] == t('Create new account') && $link['path'] == 'user/register') return;
  
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }

  return l($link['title'], $link['href'], $link['localized_options']);
}

The README.txt should also be updated to reflect this.

smk-ka’s picture

Status: Active » Postponed (maintainer needs more info)

Wow, I must say I didn't scroll down in the README for a long time. This is seriously outdated stuff...

For D6 this code snippet actually isn't required anymore. If the Create new account tab appears nonetheless for you, there must be some other module overriding invite.module's access handler. Otherwise it should alreadybe hidden, if the site accepts new user registration 'by invitation only'. Is that the case for you?

synesthete’s picture

I honestly haven't used the Invite module in this way. Had come across this thread while searching for a method to hide the "Create new account" tab in D6. Got it sorted out and thought to post the info here where someone else might find it and put it to use.