You are here

function social_profile_form_profile_profile_add_form_alter in Open Social 8.3

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  2. 8 modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  3. 8.2 modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  4. 8.4 modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  5. 8.5 modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  6. 8.6 modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  7. 8.7 modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  8. 8.8 modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  9. 10.3.x modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  10. 10.0.x modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  11. 10.1.x modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()
  12. 10.2.x modules/social_features/social_profile/social_profile.module \social_profile_form_profile_profile_add_form_alter()

Implements hook_form_FORM_ID_alter().

File

modules/social_features/social_profile/social_profile.module, line 55
The Social profile module.

Code

function social_profile_form_profile_profile_add_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
  $user = \Drupal::currentUser();

  // Check for permission on custom edit profile tags, it's only for CM+ who can
  // actually edit a users profile and add profile tags there.
  if (!$user
    ->hasPermission('edit profile tags')) {
    $form['field_profile_profile_tag']['#access'] = FALSE;
  }

  // We hide the label and form field when there are no options. This is the
  // case by default. Since we provide an empty vocabulary.
  if (empty($form['field_profile_profile_tag']['widget']['#options'])) {
    unset($form['field_profile_profile_tag']);
  }

  // Remove the save and set default submit button on profile creation.
  if (isset($form['actions']['set_default'])) {
    unset($form['actions']['set_default']);
  }
  if (isset($form['field_profile_expertise']['widget']['target_id'])) {
    $form['field_profile_expertise']['widget']['target_id']['#selection_settings']['hide_id'] = TRUE;
  }
  if (isset($form['field_profile_interests']['widget']['target_id'])) {
    $form['field_profile_interests']['widget']['target_id']['#selection_settings']['hide_id'] = TRUE;
  }

  // Add custom submit handler just for redirect purposes. We don't want to
  // override the form::save in profile.
  $form['actions']['submit']['#submit'][] = '_social_profile_profile_edit_form_submit';
}