I know variations of this question have been asked but I haven't found any with this specific set of characteristics. Also, the only programming language I know is python. I don't know PHP at all.
I want to be able to pass the value from a url parameter into a custom hidden field in the registration form.
I've tried using theme functions, template files, and hook_form_alter() but I haven't been able to get any of these to work.
So far, I've been able to add the custom field but I can't seem to hide it, let alone be able to pass the value to it. I am able to add html to the form via the template file but that's about it.
I based my attempts on this site: themery
This is the code I tried to see if I could alter the label for email.
function acq_dmc1_form_user_register_form_alter(&$form, &$form_state) {
$form['mail']['#title'] = t('E-mailzzzzzz');
$form['field_recipientid']['#title'] = t('QualID'); //this is the custom field
}
...but it didn't work.
this is the form id:
<input type="hidden" name="form_id" value="user_register_form" />
this is the HTML that's rendered for the custom field:
<input class="text-full ckeditor-mod form-text" type="text" id="edit-field-recipientid-und-0-value"
name="field_recipientid[und][0][value]" value="[url:path]" size="90" maxlength="25">
EDIT: June 17, 2013 Someone gave me this code as a solution but I don't understand if it will work or how it will work:
function passval_user_presave(&$edit, $account, $category) {
$fields = array(
'RecipientID' => array('fieldname'=>'field_recipientid', "type"=>'complex'),
'mail' => array('fieldname'=>'mail', "type"=>'simple'),
);
$urlargs = drupal_get_query_parameters();
foreach($fields as $key=>$field) {
if(isset($urlargs[$key])) {
$value = ($urlargs[$key]);
$value = intval($value);
if($field['type'] == 'complex') {
$edit[$field['fieldname']] = array('und'=>array(0=>array('value'=>$value, 'format'=>'', 'safe_value'=>$value)));
}
else {
$edit[$field['fieldname']] = $value;
}
}
}
}
if (!empty($_GET['RecipientID'])) { $RecipientID = check_plain($_GET['RecipientID']); }
Then you should be able to use $RecipientID value to assign it to whatever field you want in your form_alter. Hope this helps.