function contact_user_profile_form_submit

Same name in other branches
  1. 9 core/modules/contact/contact.module \contact_user_profile_form_submit()
  2. 10 core/modules/contact/contact.module \contact_user_profile_form_submit()
  3. 11.x 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 203

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'));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.