You are here

function content_profile_registration_user_register_submit in Content Profile 6

Submits the user registration form

1 string reference to 'content_profile_registration_user_register_submit'
content_profile_registration_add_profile_form in modules/content_profile_registration.module
Adds in the profile form of the given content type to the registration form

File

modules/content_profile_registration.module, line 246
Allows exposure and processing of content_profile node fields at user registration

Code

function content_profile_registration_user_register_submit($form, &$form_state) {
  foreach ($form['#content_profile_registration_use_types'] as $type => $typename) {
    if ($node =& $form_state['content_profile_registration'][$type]['node']) {

      // Set user's information for the node.
      if (empty($node->title) && (!module_exists('auto_nodetitle') || auto_nodetitle_get_setting($type) != AUTO_NODETITLE_OPTIONAL)) {
        $node->title = $form_state['user']->name;
      }
      $node->uid = $form_state['user']->uid;
      $node->name = $form_state['user']->name;

      // Create the node.
      $node = node_submit($node);
      node_save($node);

      // Give us a nice log message.
      if ($node->nid) {
        watchdog('content', 'Content Profile: added %user %type upon registration.', array(
          '%user' => $node->name,
          '%type' => $type,
        ), WATCHDOG_NOTICE, l(t('view'), "node/{$node->nid}"));
      }
    }
  }
}