Create a node when the user is activated
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();
  }

}