Get the user ID for a newly created user account
You don't have access to an id property. You need to use the id() method instead, e.g. $userEntity-&gt;id(). See the documentation for User.
For example:
echo &quot;User &quot; . $userEntity-&gt;id() . &quot; saved!\n\n&quot;;