Thanks! This looks like what I need to do. I will give your code a good study and try somethings.<br><br>- Carl<br><br><b><i>Alberto Lusiani <alusiani@gmail.com></i></b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> Hello,<br><br>I may have an example that might be useful for what you are asking.<br>I am working on a module that facilitates using Drupal as a conference site.<br>I am using profile to define fields for registered participants, and I<br>use form_alter in my module in order to modify the profile form. I<br>include a code fragment:<br><br>/**<br> * Implementation of hook_form_alter()<br> *<br> */<br>function tauconf_form_alter($form_id, &$form) {<br> global $form_values;<br><br> switch ($form_id) {<br><br> // [...]<br> <br> $category = 'conference registration';<br> if (isset($form[$category])) {<br><br> //<br> // change the /user/edit/conference+registration
form<br> // created with the profile module<br> // - prepend the data from /user/edit/personal+information<br> //<br><br> //--- get user data<br> $account = user_load(array('uid' => arg(1)));<br> //--- get posted data if existing for profile_form_profile()<br> $edit = $_POST['op'] ? $_POST['edit'] : (array)$account;<br><br> //--- include "personal info" form<br> $form[$category]['personal_information'] =<br> profile_form_profile($edit, $account, "personal information");<br> $form[$category]['personal_information']['#weight'] = -5;<br><br> //<br> // setup validation callback for 'conference registration' profile form<br> //<br> $form[$category]['#validate'] =<br> array('tauconf_registration_validate' =><br> array(&$form_values, $account));<br><br> //--- customize MAC address field<br> $field = 'profile_mac_address';<br> if (isset($form[$category][$field])) {<br>
$form[$category][$field]['#maxlength'] = 17;<br> $form[$category][$field]['#size'] = 17;<br> }<br><br><br> //--- set default value of arriving date<br> $field = 'profile_arrival_date';<br> if (isset($form[$category][$field])) {<br> $time = strtotime("2006-09-18 12:00");<br> $form[$category][$field]['#default_value'] =<br> array('day' => format_date($time, 'custom', 'j'),<br> 'month' => format_date($time, 'custom', 'n'),<br> 'year' => format_date($time, 'custom', 'Y'));<br> }<br><br> //--- set default value of departure date<br> $field = 'profile_departure_date';<br> if (isset($form[$category][$field])) {<br> $time = strtotime("2006-09-22 16:00");<br> $form[$category][$field]['#default_value'] =<br> array('day' => format_date($time, 'custom', 'j'),<br> 'month' => format_date($time, 'custom', 'n'),<br> 'year' => format_date($time, 'custom', 'Y'));<br> }<br><br> //<br> // prevent registration
if:<br> // - registrations are not open<br> // - the e-mail is not invited<br> //<br> $field = 'profile_register_to_conference';<br> if (isset($form[$category][$field])) {<br> $form[$category][$field]['#weight'] = 5;<br> $can_register = false;<br> switch (variable_get('tauconf_reg_status', 'not_yet_open')) {<br> case 'open':<br> if (!array_search('invited', $account->roles)) {<br> $msg = variable_get('tauconf_msg_not_invited','');<br> $msg = str_replace('%user_name%', $account->name, $msg);<br> $msg = str_replace('%user_mail%', $account->mail, $msg);<br> $msg = str_replace('%contact_admin%',<br> l(t('contact'), 'contact',<br> array('title' =><br> t('Contact the site administrator'))),<br> $msg);<br> } else {<br> $can_register = true;<br> }<br> break;<br> case 'closed':<br> $msg = variable_get('tauconf_msg_reg_closed', '');<br> $can_register = false;<br> break;<br> case
'not_yet_open':<br> default:<br> $msg = variable_get('tauconf_msg_reg_not_yet_open', '');<br> $can_register = false;<br> break;<br> }<br><br> $can_unregister = array_search('registered', $account->roles);<br><br> if (!$can_register) {<br> //<br> // replace checkbox for registration with explicative message<br> //<br> //--- replace null message with some info<br> if ($msg == '') {<br> $msg =<br> '<div class="form-item">' .<br> '<div class="messages error">' . "\n" .<br> '<label>Registration unavailable.</label>' .<br> '</div>' . "\n" . $msg . "\n" . '</div>';<br> }<br> //--- inform that registratoin is not available<br> if ($can_unregister) {<br> $msg =<br> $msg .<br> "If you unregister, you won't be able to register again.";<br> }<br> $form[$category]['msg'] = array(<br> '#title' => t('Registration not available'),<br> '#value' => $msg,<br> '#weight' => 4,<br> );<br>
if (!$can_unregister && !user_access('administer conference')) {<br> //--- hide registration checkbox<br> $form[$category][$field]['#type'] = 'hidden';<br> $form[$category]['reg_status'] = array(<br> '#title' => t('Registration status'),<br> '#value' =><br> array_search('registered', $account->roles) ?<br> "Status: <strong>registered</strong>" :<br> "Status: <strong>not</strong> registered",<br> '#weight' => 5,<br> );<br> }<br> }<br> }<br> }<br> break;<br> }<br>}<br><br>Greetings,<br>-- <br>Alberto<br></blockquote><br><BR><BR><div> <div><font face="Arial" size="2">Carl Mc Dade<br>____________________________<br>Web Developer<br>Dataföreningen i Sverige AB<br>www.d4d.se<br>www.dfs.se<br></font></div><div><font face="Arial" size="2"><br> </font></div></div><p> 
                <hr size=1>Do you Yahoo!?<br> Next-gen email? Have it all with the <a href="http://us.rd.yahoo.com/evt=42241/*http://advision.webevents.yahoo.com/handraisers"> all-new Yahoo! Mail Beta.</a>