function profile2_form_user_profile_form_alter in Profile 2 7
Same name and namespace in other branches
- 7.2 profile2.module \profile2_form_user_profile_form_alter()
Implements hook_form_FORM_ID_alter() for the user edit form.
See also
profile2_form_validate_handler
profile2_form_submit_handler
File
- ./
profile2.module, line 420 - Support for configurable user profiles.
Code
function profile2_form_user_profile_form_alter(&$form, &$form_state) {
global $user;
if (($type = profile2_get_types($form['#user_category'])) && $type->userCategory) {
if (empty($form_state['profiles'])) {
$profile = profile2_load_by_user($form['#user'], $form['#user_category']);
if (empty($profile)) {
$profile = profile2_create(array(
'type' => $form['#user_category'],
'uid' => $form['#user']->uid,
));
$profile->is_new = TRUE;
}
$form_state['profiles'][$profile->type] = $profile;
if (user_access('administer profiles') || $user->uid === $profile->uid && user_access("delete own {$profile->type} profile")) {
$str_button_value = t('Delete profile');
}
}
if (empty($profile->is_new) && !empty($str_button_value)) {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => $str_button_value,
'#weight' => 45,
'#limit_validation_errors' => array(),
'#submit' => array(
'profile2_form_submit_own_delete',
),
);
}
profile2_attach_form($form, $form_state);
}
}