All,
What I want to do: On the Home page, I have an input field in which a user can insert their invite code, the invite code gets validated via ajax and if correct, popups the registration form. Its important that the user cannot get access to the registration form without the correct invite code. How can I bullet proof this concept into my Drupal7 install? I am using Regcode module for registration purpose.
The problem I have is that if the user knows the address to the registration form, they can merely enter that into the browser's address bar and register without having to gain an invite code.
One solution I thought was that the invite code is needed on the actual registration form as well, so if they do access the form via the browser's address bar, they will still need to input the invite code. However, if they already did place the invite code in the input field (on the Home page), it would automatically populate the invite code field in the registration form.
What problem I am facing: Im not sure how to go about transferring the invite code (which the user inserted) into the registration form that pops up upon validation. The form(single field) on the front page is written by myself inside a block.
Here i am confused how to take the form value to the registration form and how to get the value of field and after getting how to set the value as default in the regcode text field.
<form method="GET" action="?????"></form>
the modulea's part which alter the registration form is as follows
function regcode_form_user_register_form_alter(&$form, &$form_state) {
$code_optional = variable_get('regcode_optional', FALSE);
$account = $form['#user'];
$form['regcode']['regcode_code'] = array(
'#type' => 'textfield',
'#title' => variable_get('regcode_field_title', t('Registration Code')),
'#description' => variable_get('regcode_field_description', t('Please enter your registration code.')),
'#default_value' => ???????????,
'#required' => !($code_optional || user_access('administer users')),
'#element_validate' => array('regcode_code_element_validate'),
);
// 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;
}
}
i Hope, its understandable now