You are here

function google_analytics_user_profile_form_submit in Google Analytics 8.2

Same name and namespace in other branches
  1. 8.3 google_analytics.module \google_analytics_user_profile_form_submit()
  2. 4.x google_analytics.module \google_analytics_user_profile_form_submit()

Submit callback for user profile form to save the Google Analytics setting.

1 string reference to 'google_analytics_user_profile_form_submit'
google_analytics_form_user_form_alter in ./google_analytics.module
Implements hook_form_FORM_ID_alter().

File

./google_analytics.module, line 431
Drupal Module: Google Analytics.

Code

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