Get node ID in a form submit I am struggling with how to get node id in my user_register_form_submit.
I need to get the node id of the node where my form is, let me explain :

I have created a tpl for my user register form in order to print it in nodes of a special content type, those nodes prepopulate my form and helps to create users, I need this node id to delete the node after submiting the form wich means delete the node after a user is created.

here is my hook :

    function hook_form_alter(&amp;$form, &amp;$form_state, $form_id) {
        if($form_id == 'user_register_form'){
            $form['#submit'][] = 'user_register_form_submit';
        }
    }

    function user_register_form_submit($form, &amp;$form_state) {
    // print the node id
    }


Last thing, I'm working with Drupal 7.
Thanks !
For Drupal 8 Add your custom submit handler in form alter:

$form['actions']['submit']['#submit'][] = '_custom_node_form_submit';


And add custom submit handler:

function _custom_node_form_submit($form, \Drupal\Core\Form\FormStateInterface $form_state) {
  echo $form_state-&gt;getValue('nid');
}