function matomo_user_profile_form_submit in Matomo Analytics 8
Submit callback for user profile form to save the Matomo setting.
1 string reference to 'matomo_user_profile_form_submit'
- matomo_form_user_form_alter in ./
matomo.module - Implements hook_form_FORM_ID_alter().
File
- ./
matomo.module, line 427 - Drupal Module: Matomo.
Code
function matomo_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('matomo', $account
->id(), 'user_account_users', (int) $form_state
->getValue('user_account_users'));
}
// Remove old piwik setting to complete migration to matomo.
$account_data_piwik = \Drupal::service('user.data')
->get('piwik', $account
->id());
if (isset($account_data_piwik)) {
\Drupal::service('user.data')
->delete('piwik', $account
->id());
}
}