W3cubDocs

/Drupal 8

function contact_user_profile_form_submit

contact_user_profile_form_submit($form, FormStateInterface $form_state)

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

File

core/modules/contact/contact.module, line 192
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'));
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!contact!contact.module/function/contact_user_profile_form_submit/8.1.x