Closed (fixed)
Project:
Registration codes
Version:
6.x-2.6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Feb 2011 at 08:24 UTC
Updated:
4 Mar 2011 at 07:41 UTC
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
Comment #1
aidanlis commentedThis seems like a very reasonable change, I'll implement it in the next version.
Comment #2
aidanlis commented