function signup_form_user_register_form_alter in Signup 7
Implements hook_form_FORM_ID_alter().
Related topics
File
- ./
signup.module, line 706 - The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…
Code
function signup_form_user_register_form_alter(&$form, &$form_state) {
// Get a list of nodes that should appear on the user registration form.
$query = db_select('node', 'n');
$alias = $query
->join('signup', 's', 'n.nid = s.nid');
$query
->fields('n', array(
'nid',
));
$query
->condition("n.status", 1)
->condition("{$alias}.user_reg_form", 1)
->condition("{$alias}.status", 1);
$query
->addTag('node_access');
$nids = $query
->execute()
->fetchCol();
// Allow other modules to alter the list of nids.
drupal_alter('signup_user_reg_nids', $nids);
// If there is at least one node, add the Signup fieldset.
if (!empty($nids)) {
$form['signup'] = array(
'#type' => 'fieldset',
'#title' => t('Event signup'),
'#tree' => TRUE,
'#description' => t('You will be automatically signed up once your account is created.'),
);
// Each node gets a checkbox.
foreach ($nids as $nid) {
$node = node_load($nid);
$form['signup'][$nid] = array(
'#type' => 'checkbox',
'#title' => theme('signup_node_title', array(
'node' => $node,
)),
'#default_value' => 0,
);
}
}
}