I have about 3 profile types each with their own registration path. But there's one without a path. I want to attach this to the main registration form. So that it shows when adding user on the main user add page but not other pages.

i got it to show with the code below but error when saving the user.

Recoverable fatal error: Argument 1 passed to profile2_save() must be an instance of Profile, instance of ProfileType given,, called in C://....

function short_fixes_form_user_register_form_alter(&$form, &$form_state) {
  global $user;
  $current_user_role = in_array('family',$user->roles);
  $form['account']['status']['#access'] = FALSE ;
  if($_GET['q'] == 'admin/people/create' && $current_user_role){
      $form_state['profiles'] = array(
        'family' => profile2_get_types('family')
      profile2_attach_form($form, $form_state);

1 Answer 1


try this,

$user_register_form = drupal_get_form('user_register_form');
$form_state['profiles'] = array(
profile2_attach_form($user_register_form, $form_state);
  • Thanks. This gives a huge clue on how i eventually got it working. I'm only doing this through hook_form_user_register_form_alter(&$form, &$form_state). It works. Thank you. Commented May 9, 2017 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.