Same name and namespace in other branches
  1. 8.9.x core/modules/contact/contact.module \contact_user_profile_form_submit()
  2. 9 core/modules/contact/contact.module \contact_user_profile_form_submit()

Submit callback for the user profile form to save the contact page setting.

1 string reference to 'contact_user_profile_form_submit'
contact_form_user_form_alter in core/modules/contact/contact.module
Implements hook_form_FORM_ID_alter().

File

core/modules/contact/contact.module, line 209
Enables the use of personal and site-wide contact forms.

Code

function contact_user_profile_form_submit($form, FormStateInterface $form_state) {
  $account = $form_state
    ->getFormObject()
    ->getEntity();
  if ($account
    ->id() && $form_state
    ->hasValue('contact')) {
    \Drupal::service('user.data')
      ->set('contact', $account
      ->id(), 'enabled', (int) $form_state
      ->getValue('contact'));
  }
}