hook_user_insert not being called I've got a custom module weekly_digest and I want to make it so each new user is added to a table with info on their subscription preferences.

I've been using the admin UI to add the users to test, unsure if that effects things but I don't see why it would.

As some context, in my .module I currently have weekly_digest_node_insert and that works just fine.

And here is the function which does not get executed and I can't get Xdebug to catch it either:

function weekly_digest_user_insert(UserInterface $entity) {

  $query = Drupal::database()-&gt;insert('weekly_digest_user_preferences');
  $query-&gt;fields([
    'uid',
  ])-&gt;useDefaults([
    'new_posts',
    'digests',
  ])-&gt;values([
    $entity-&gt;id(),
  ])-&gt;execute();

}


Most search results returned "Can't in theme" or "Drupal 7" so I was unable to figure this out.
It could be that you are using the incorrect argument. hook_ENTITY_TYPE_insert is a generic hook, it's not opinionated about what entity you are "inserting" (E.g. it could be a node, taxonomy, user...)

Try:

function weekly_digest_user_insert(\Drupal\Core\Entity\EntityInterface $entity) {
  // Do stuff.
}