How do I trigger group membership was granted for a user - Group module
as @Jaypan suggested to me,
I used hook_ENTITY_TYPE_insert()
so my code is:
function hook_group_content_insert(GroupContentInterface $group_content) {
  if ($group_content-&gt;hasField('entity_id')
    &amp;&amp; !$group_content-&gt;get('entity_id')-&gt;isEmpty()) {
    $users = $group_content-&gt;get('entity_id')-&gt;referencedEntities();
    $user = reset($users);
    if ($user instanceof UserInterface) {
      // Do your code here.
    }
  }
}