Create a node when the user is activated Drupal Version: 8.92
Part 1. I am trying to create a node when the user is activated by the administrator for the first time. However, I am not able to find the right event/hook to execute the code. I tried &quot;user_activated&quot; but it is not working.
function my_module_user_activated(\Drupal\user\UserInterface $user) {
  \Drupal\node\Entity\Node::create([
    'type' =&gt; 'my_node',
    'title' =&gt; $user-&gt;getDisplayName(),
    'uid' =&gt; $user-&gt;id(),
  ])-&gt;save();
}

Any pointers?
PS: I don't want to create the node using hook_user_insert().
Part 2. If I need to delay the node creation to user validating the email by clicking a URL, what hook should I try?
Thank You!
Uri
Modified code based on the pointers from No Sssweat. The working code is below for any future references.
function &lt;MY-MODULE&gt;_user_presave(\Drupal\user\UserInterface $user) {
  if (($user-&gt;isActive()) and ($user-&gt;getLastAccessedTime() == 0 ) and ( $user-&gt;hasRole('role_name'))){
  \Drupal\node\Entity\Node::create([
    'type' =&gt; 'my_content_type',
    'title' =&gt; $user-&gt;getDisplayName(),
    'uid' =&gt; $user-&gt;id(),
  ])-&gt;save();
  }

}