Active
Project:
Event Manager
Version:
5.x-1.0
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Apr 2008 at 16:21 UTC
Updated:
24 Nov 2008 at 19:37 UTC
Hello,
Can you tell me how to autofill the email / name / etc... on an event registration? We pull our users from LDAP and I would like to event registration form to automatically fill in their email, etc... from their profile.
ANy help is much appreciated. Contact me if you need more information.
Comments
Comment #1
mdowsett commentedI'm also interested in this sort of thing....but I am using the location module to get the users address upon account registration (so you can plot users on a map). That info goes into their Bio user profile node. I'd then like to pre-populate the event registration form with info from their Bio so they don't have to retype it.
...and for an added bonus, it'd be nice that if they change their registration info from the stored pre-populated info, it'd change their Bio...
Comment #2
kaw3939 commenteddid you get this fixed for yourself?
This is code out of my template.php file that is in the theme pixture:
The real trick here is that you need to use " global $user " and " $profile = profile_load_profile($user); to get the profile data for the current user. Then you can use that information to fill the form in. There is an if statement in my code that is just to determine anonymous and authenticated users.
function pixture_signup_user_form() {
global $user;
$profile = profile_load_profile($user);
// This line is required for this form to function -- DO NOT EDIT OR REMOVE.
$form['signup_form_data']['#tree'] = TRUE;
if ($user->uid) {
$form['signup_form_data']['First_Name'] = array(
'#type' => 'textfield',
'#title' => t('First Name'),
'#default_value' => $user->profile_fname,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Last_Name'] = array(
'#type' => 'textfield',
'#title' => t('Last Name'),
'#default_value' => $user->profile_lname,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $user->profile_title,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Status'] = array(
'#type' => 'textfield',
'#title' => t('Status'),
'#default_value' => $user->profile_status,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Department'] = array(
'#type' => 'textfield',
'#title' => t('Department'),
'#default_value' => $user->profile_department,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Phone'] = array(
'#type' => 'textfield',
'#title' => t('Phone'),
'#default_value' => $user->profile_officephone,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Additional_Phone'] = array(
'#type' => 'textfield',
'#title' => t('Additional Phone Number'),
'#default_value' => $user->profile_officephone,
'#size' => 40, '#maxlength' => 64,
);
}else {
$form['signup_form_data']['First_Name'] = array(
'#type' => 'textfield',
'#title' => t('First Name'),
'#default_value' => $user->profile_fname,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Last_Name'] = array(
'#type' => 'textfield',
'#title' => t('Last Name'),
'#default_value' => $user->profile_lname,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $user->profile_title,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Status'] = array(
'#type' => 'textfield',
'#title' => t('Status'),
'#default_value' => $user->profile_status,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Department'] = array(
'#type' => 'textfield',
'#title' => t('Department'),
'#default_value' => $user->profile_department,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Phone'] = array(
'#type' => 'textfield',
'#title' => t('Phone'),
'#default_value' => $user->profile_officephone,
'#size' => 40, '#maxlength' => 64,
'#required'=> true
);
$form['signup_form_data']['Additional_Phone'] = array(
'#type' => 'textfield',
'#title' => t('Additional Phone Number'),
'#default_value' => $user->profile_officephone,
'#size' => 40, '#maxlength' => 64,
);
}
// If the user is logged in, fill in their name by default.
if ($user->uid) {
$form['signup_form_data']['Name']['#default_value'] = $user->name;
}
return $form;
}
Comment #3
Dubber Dan commentedkaw3939 - Useful looking code, thanks.
Would be ideal if this could be built into the module :-)
Comment #4
Dubber Dan commentedHmm, tried that code, changing pixture for the name of my theme but it doesn't seem to do anything.
No errors, nothing, just a blank form as usual. Any suggestions?