0

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

1

try this,

$user_register_form = drupal_get_form('user_register_form'); $form_state['profiles'] = array( 'CUSTOM_PROFILE_TYPE_NAME' => profile2_get_types('CUSTOM_PROFILE_TYPE_NAME') ); profile2_attach_form($user_register_form, $form_state); print(drupal_render($user_register_form)); 
1
  • 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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.