title: Is it possible to access nodes created with inline entity forms in Drupal 8 in a form alter hook?
body: <p>I am working on a Drupal site that models a Family content type with entity references to Children and Parent content types. Families are entered in a single form, and I am using the inline entity form module (IEF) to enable entry of parent and child information in the same form. My goal is to allow anonymous users to create a user account by filling out this form. Currently, I have a custom module that implements hook_form_FORM_ID_alter and adds a function to the submit action that creates a new user account and sets the owner of the outer form node (the Family node in this case):</p>
  <pre class="lang-php prettyprint-override"><code>    function myModule_form_node_family_form_alter(&amp;$form, &amp;$form_state, $form_id){ 
          #register function on submit as that's when the node id of the created entity is available              
          $form['actions']['submit']['#submit'][] = 'signup_submit';
      }
      function signup_submit($form, &amp;$form_state){
          #get node id of newly created entity
          $nid = $form_state-&gt;getValue('nid');
          #create user
          $email = $form_state-&gt;getValue('field_email_address')[0]['value'];
          $user = \Drupal\user\Entity\User::create();
          $user-&gt;setEmail($email);
          $user-&gt;enforceIsNew();
          $user-&gt;setPassword(getRandomPassword());
          $user-&gt;setUsername(genUsername($nid));
          if($res){
                 #set user to be owner of newly created node
                 dpm(&quot;User &quot;.$user-&gt;id().&quot;created successfully!&quot;);
                 $node = node_load($nid);
                 $node-&gt;setOwner($user);
                 $node-&gt;save();
          }
      }
  </code></pre>
  <p>I was hoping to do the same thing for the nodes created with IEF using a similar pattern:</p>
  <pre class="lang-php prettyprint-override"><code>function myModule_inline_entity_form_entity_form_alter(&amp;$entity_form, &amp;$form_state){
          $entity_form['actions']['submit']['#submit'][] = 'inline_submit';
  }
  function inline_submit(&amp;$entity_form, &amp;$form_state){
          $nid = $form_state-&gt;getValue('nid');
          dpm(&quot;nid of inline entity: &quot;.$nid);
  }
  </code></pre>
  <p>... But it doesn't seem to work. If anyone knows when the nodes are actually created and how I could access the node id's so I can change the ownership, I would be greatly appreciative!</p>