You are here

function signup_profile_form in Signup 6.2

Signup form pane callback.

Parameters

&$signup_form: The form array for the whole signup. You should not alter this, but it contains useful data depending on circumstances.

&$form_state: Likewise.

$node: The fully loaded node object.

$signup: If this is an existing signup, the fully loaded signup object. If this is a new signup, this is just NULL.

$pane_id: The pane ID being invoked. This allows a module to implement multiple panes with one callback.

$signup_type: Determines what kind of signup to generate a form for. Possible values: 'auth' -- regular authenticated user signup form 'anon' -- anonymous user signup form (includes required email field). 'admin' -- admin form to signup another user (includes user selector).

Return value

A form API array for insertion into the signup form.

1 string reference to 'signup_profile_form'
signup_profile_signup_pane_info in modules/signup_profile/signup_profile.module
Implementation of hook_signup_pane_info().

File

modules/signup_profile/signup_profile.module, line 99
signup_profile.module Provides integration with profile module.

Code

function signup_profile_form(&$signup_form, &$form_state, $node, $signup, $pane_id, $signup_type = 'auth') {
  $form = array();

  // Get the real category name from the prefixed pane ID.
  $category = substr($pane_id, 8);

  // Call profile.module's implementation of hook_user's form op.
  // This is a smidgen hacky, but safe, as:
  // - $edit is just checked for default values, passing nothing won't hurt.
  //   @todo: make this bit work for bonus points!
  // - $user is not looked at at all.
  $form = profile_form_profile(array(), NULL, $category, FALSE);

  // Our data is not in the signup data, so we prepopulate this form
  // with our own default values where applicable.
  if (isset($signup) && $signup_type != 'anon') {

    // Existing signup: get the account.
    $account = user_load($signup->uid);
  }
  elseif ($signup_type == 'auth') {

    // An authenticated user is signup themselves up.
    // Prefill their profile values so they can either leave them or know what
    // they are changing.
    global $user;

    // Need to do a user_load to get profile fields.
    $account = user_load($user->uid);
  }
  if (isset($account)) {

    // Set the form's defaults to the profile values.
    foreach (element_children($form[$category]) as $key) {
      $form[$category][$key]['#default_value'] = $account->{$key};
    }
    $form[$category]['#description'] = t('This information is from your @site-name user profile; changes you make here will be saved into it.', array(
      '@site-name' => variable_get('site_name', 'Drupal'),
    ));
  }
  return $form;
}