fixed user edit form

This commit is contained in:
Bachir Soussi Chiadmi 2022-11-15 09:33:59 +01:00
parent 83a6f13a10
commit 5bd907ec1e
1 changed files with 3 additions and 1 deletions

View File

@ -25,11 +25,13 @@ function materio_commerce_form_commerce_order_add_form_alter(&$form, &$form_stat
} }
function materio_commerce_form_user_form_alter(&$form, &$form_state, $form_id) { function materio_commerce_form_user_form_alter(&$form, &$form_state, $form_id) {
if ($form_id !== 'user_form') return;
$mail = $form['account']['mail']['#default_value']; $mail = $form['account']['mail']['#default_value'];
$user_storage = \Drupal::entityTypeManager()->getStorage('user'); $user_storage = \Drupal::entityTypeManager()->getStorage('user');
$users = $user_storage->loadByProperties(['mail' => $mail]); $users = $user_storage->loadByProperties(['mail' => $mail]);
$user = reset($users); $user = reset($users);
$roles = $user->getRoles(); // $roles = $user->getRoles();
$license_storage = \Drupal::entityTypeManager()->getStorage('commerce_license'); $license_storage = \Drupal::entityTypeManager()->getStorage('commerce_license');
$licenses = $license_storage->loadByProperties(['uid' => $user->id()]); $licenses = $license_storage->loadByProperties(['uid' => $user->id()]);