Hi, I'm using Drupal 5.0 beta 1 with the invite module (using AjK's Drupal5 patch) and have been trying to implement a feature so that new user registrations to the site can only occur if the user has been invited.

I'm stuck on how to use the FormAPI's to correctly remove the 'Create a new user account' link from the user_login_block.

I've used the invite_form_alter hook to:
- Add an 'By invitation only' option into the user_admin_settings form
- Further modify the user_register form so that if a valid invite isn't presented drupal_goto('/user') is called
- Catch the ['#submit']['user_register_submit'] to provide initial validation.

What I'm stuck on is how to remove the 'Create a new user account' links if the invite only option is selected.
I'm pretty new to drupal code, so don't quite know how to use all the FormAPI's, but my best guess in the invite_form_alter I do something akin to this:

case 'user_login_block':
      if (variable_get('user_register',1) == 'inviteonly') {
        drupal_set_message(var_export($form['links']['#value'], true));
        $register_link = l(t('Create new account'), 'user/register', array('title' => t('Create a new user account.')));
        $stripped_block = str_replace($register_link, '', $form['links']['#value']);
        $form['links']['#value'] = $stripped_block;
      }
      break;

Am I using the wrong approach?
The code above leaves a list item in the login block which I want to remove. I also want to strip the equivalent link from the user_login(?) form.

If there is a useful example I've missed, or if someone could tell me exactly what to do that would be great.
Ideally, I'd stop the user module from adding the link in the first place but can't think of good hooking logic to do so.

Comments

Nick Wilson’s picture

Status: Active » Closed (won't fix)

Hi, unfortunately im only caretaking this module, so if you can test/verify your code and submit a patch i'lll be happy to consider it for implementation

thanks