function google_analytics_user_profile_form_submit in Google Analytics 4.x
Same name and namespace in other branches
- 8.3 google_analytics.module \google_analytics_user_profile_form_submit()
- 8.2 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 439 - Drupal Module: Google Analytics.
Code
function google_analytics_user_profile_form_submit($form, FormStateInterface $form_state) {
/** @var Drupal\user\ProfileForm $profileForm */
$profileForm = $form_state
->getFormObject();
/** @var Drupal\user\Entity\User $account */
$account = $profileForm
->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'));
}
}