The code that tries to to capture regcode from the URL does not seem to work in Drupal 6.20

      // Capture the code from the url and inject it into the registration form
      if (arg(2) === 'regcode' && arg(3)) {
        $form['regcode']['regcode_code']['#value']       = check_plain(arg(3));
        $form['regcode']['regcode_code']['#description'] = NULL;
        $form['regcode']['regcode_code']['#disabled']    = TRUE;
      }

This implieas that the url http://www.example.com/user/register/regcode/mycode should be used.
However the core user module does not allow for additional arguments in the path defined in it's hook_menu (see snippet from user.module below).

  $items['user/register'] = array(
    'title' => 'Create new account',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('user_register'),
    'access callback' => 'user_register_access',
    'type' => MENU_LOCAL_TASK,
    'file' => 'user.pages.inc',
  );

Thus giving the regcode as part of the path will only generate a 404 Not Found.

A better solution would be to change the URL used by regcode to
http://www.example.com/user/register?regcode=mycode

So changing the code in regcode.module to something like

      // Capture the code from the url and inject it into the registration form
      if ( isset($_GET['regcode')) {
        $form['regcode']['regcode_code']['#value']       = check_plain($_GET['regcode'));
        $form['regcode']['regcode_code']['#description'] = NULL;
        $form['regcode']['regcode_code']['#disabled']    = TRUE;
      }

Then we would not be forced to rely on paths defined in core modules.

Comments

aidanlis’s picture

This seems like a very reasonable change, I'll implement it in the next version.

aidanlis’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.