access values submited during registration

How to access values submited during registration

function demomail_entity_insert(DrupalCoreEntityEntityInterface $entity ) {
 
  if ($entity->getEntityTypeId() == ‘user’){

  $mailManager = Drupal::service(‘plugin.manager.mail’);

  $module = ‘demomail’;
  $key = ‘create_article’;
  $to = ‘[email protected]‘;
  $params[‘message’] = ‘a’;
  $params[‘node_title’] = ‘lel’;
  $langcode = Drupal::currentUser()->getPreferredLangcode();
  $send = true;

  $result = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);
  if ($result[‘result’] !== true) {
    drupal_set_message(t(‘There was a problem sending your message and it was not sent.’), ‘error’);
  }
  else {
    drupal_set_message(t(‘Your message has been sent.’));
  }}

}

This is my custom module which executes when a new user is registered. I want to access the value of a custom field in registration form .

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed