Created
December 17, 2013 21:10
-
-
Save mdeltito/8012687 to your computer and use it in GitHub Desktop.
adding profile2 entity form fields to a node form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* implements hook_form_FORM_ID_alter | |
*/ | |
function report_form_node_form_alter(&$form, &$form_state, $form_id) { | |
if ($form_id == 'report_node_form') { | |
// the node author's uid is always available here | |
$account = user_load($form['#node']->uid); | |
if (empty($form_state['profiles']['personal'])) { | |
$profile = profile2_load_by_user($account, 'personal'); | |
if ($profile) { | |
$form_state['profiles'][$profile->type] = $profile; | |
profile2_attach_form($form, $form_state); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment