Execute a custom function on 'user register' or 'login'
You can do this using the following hooks in your module.


hook_user_login
hook_user_register (In D7 we had user_insert hook.)


Examples:

User Login Hook:

function mymodule_user_login($account){

   //your code here
}


User Register Hook:

function mymodule_user_insert(Drupal\Core\Entity\EntityInterface $entity){

   //your code here

}