Hi,

I'm using Content Profile 6.x-1.0-beta4 with Drupal 6.16 and I've themed my user registration form. When the user registration form uses just the default fields everything gets saved in the database however when I add a content profile field (in this case a mobile phone field which is part of a "personal info" content profile group) this field data doesn't get saved when the user registers. If they proceed to their profile page the mobile phone field is empty.

I've tried searching for custom user registration theming help - of which there is plenty - but still can't see to get the below to work. Any help would be much appreciated.

Thank you.

Template.php

/**
* Implementation of hook_theme().
*/
function my_theme() {
  return array(
    'user_register' => array('arguments' => array('form' => NULL), 'template' => 'user-register-form',),
  );
}


function my_preprocess_user_register(&$vars) {  
  //Account Information
  $vars['form']['account']['#title'] = t('Your Registration Information');  
  $vars['form']['account']['name']['#prefix'] = '<div id="username-warning">Your username is the name you\'ll be known as on the website. <strong>Once set it cannot be changed</strong>.</div>';
  $vars['form']['account']['name']['#description'] = t('Spaces are allowed; punctuation is not allowed except for full stops, hyphens, and underscores');  
  $vars['form']['account']['name']['#suffix'] = '<div class="clear"></div>';
  
  //Email Fields
  $vars['form']['account']['mail']['#description'] = t('A valid email address. All emails from the club will be sent to this address. The email address will not be visible to others and will only be used if you wish to receive a new password or wish to receive certain news or notifications by email.');
  
  // Rename the Save and Delete buttons to be more clear.
  $vars['form']['submit']['#value'] = t('Register');
  
  // Prepare all of the desired form elements as variables, to be used in user-register-form.tpl.php.
  // Everything before this part is optional.
  $vars['account'] = drupal_render($vars['form']['account']);
  $vars['profile'] = drupal_render($vars['form']['group_cprofile_personal_info']);
  $vars['simple_news'] = drupal_render($vars['form']['simplenews']);
  $vars['submit'] = drupal_render($vars['form']['submit']);
}

user-register-form.tpl.php

  print $account;
  print $email;
  print $profile;
  print $simple_news;
  print $submit;
  print drupal_render($form);

Comments

victoria_b’s picture

Hi,

Sorry for the bump. Could anyone help me out or point me in the right direction? Would be much appreciated.

Thank you.

harvlad’s picture

Add this to the end of your user_register function

$variables['rendered'] = drupal_render($variables['form']);

It should ensure the rest of the form is rendered, including the bits you cant see