You are here

function private_message_user_form_submit in Private Message 8.2

Same name and namespace in other branches
  1. 8 private_message.module \private_message_user_form_submit()

Custom submit handler, saves user settings for the private message module.

See also

private_message_form_user_form_alter()

1 string reference to 'private_message_user_form_submit'
private_message_form_user_form_alter in ./private_message.module
Implements hook_form_FORM_ID_alter().

File

./private_message.module, line 360
Contains hooks for the private message module.

Code

function private_message_user_form_submit(array &$form, FormStateInterface $formState) {

  // Get the user whose account object is being modified.
  $user = $formState
    ->getFormObject()
    ->getEntity();
  $user_data = \Drupal::service('user.data');

  // Save the submitted data to the user's UserData.
  $user_data
    ->set('private_message', $user
    ->id(), 'receive_notification', $formState
    ->getValue([
    'private_messages',
    'receive_notification',
  ]));
  $user_data
    ->set('private_message', $user
    ->id(), 'notify_when_using', $formState
    ->getValue([
    'private_messages',
    'notify_when_using',
  ]));
  $user_data
    ->set('private_message', $user
    ->id(), 'number_of_seconds_considered_away', $formState
    ->getValue([
    'private_messages',
    'number_of_seconds_considered_away',
  ]));
}