You are here

function signup_profile_signup_data_alter in Signup 6.2

Implementation of hook_signup_data_alter().

This allows us to alter the signup data prior to it being saved, do our own saving of profile data, and remove the profile data from the signup so it is not saved in the {signup_log} table's serialized array.

File

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

Code

function signup_profile_signup_data_alter(&$signup, $form_values) {

  // Check we have incoming data that concerns us.
  foreach ($signup->form_data as $pane_id => $form_data_pane) {
    if (substr($pane_id, 0, 7) == 'profile') {
      $profile_pane_ids[] = $pane_id;
    }
  }
  if (isset($profile_pane_ids)) {

    // Get the user account.
    $account = user_load($signup->uid);
    foreach ($profile_pane_ids as $pane_id) {

      // Get the real category name from the prefixed pane ID.
      $category_name = substr($pane_id, 8);
      $profile_data = $signup->form_data['profile_' . $category_name][$category_name];

      // Again, a bit hackish, but probably safe to call:
      // function profile_save_profile(&$edit, &$user, $category, $register = FALSE)
      // $edit is an array of form element ID => value which we have too.
      // $user we pass the account for the signup.
      profile_save_profile($profile_data, $account, $category_name, FALSE);

      // Unset our data from the signup so it's not saved redundantly.
      unset($signup->form_data[$pane_id]);
    }
  }
}