enable/disable node_save programmatically I created a custom module that can save nodes. 

I want a checkbox that determines whether the node will be saved or not.

This is the node_save program : 

     global $user;

// IF (FORM_STATE [VALUE][CHECKBOX] == Checked ! ) {


        $node = new stdClass();
        $node-&gt;type = "services";
        node_object_prepare($node);
        $node-&gt;language = 'fr'; // Or e.g. 'en' if locale is enabled
        $node-&gt;uid = $user-&gt;uid;
        $node-&gt;status = 1; //(1 or 0): published or not
        $node-&gt;promote = 0; //(1 or 0): promoted to front page
        $node-&gt;comment = 1; // 0 = comments disabled, 1 = read only, 2 = read/write
        $node-&gt;title = $form_state['values']['produit_de_client'];

        $node-&gt;field_produit_dc['und'][0]['value'] = $produit;
          $node-&gt;field_espace_dediee_categories[LANGUAGE_NONE][0]['tid']=$form_state['values']['espace_dediee'];


        $node-&gt;body['und'][0]['value'] =$form_state['values']['text_service'];
        $node-&gt;body['und'][0]['format'] ='full_html';

        $aaz= array_filter($form_state['values']['wrapperrr']['id_offre']);
     foreach($aaz as $of)
       {       

       $node-&gt;field_offre[LANGUAGE_NONE][]['target_id'] = $of;



       } 

        $node-&gt;field_id_prod['und'][0]['value'] = $produit;
            $file = file_load($form_state['values']['image_dc']);
            $file-&gt;status = FILE_STATUS_PERMANENT;

            $uploaded = file_save($file);
            $aaa = file_create_url($file-&gt;uri);
        $node-&gt;field_produit_dc['und'][0]['value'] = $file-&gt;fid;
        $url = $file-&gt;uri;

        $node-&gt;field_image_serv[LANGUAGE_NONE][0]['fid'] = $file-&gt;fid;

        node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().



        $node = node_submit($node); // Prepare node for saving
        node_save($node);

//ELSE NO NODE WILL BE SAVED
In a nutshell:

function mymodule_form_submit($form, &amp;$form_state) {
  if ($form_state['values']['mycheckbox'] == 1) {
    // node code...
    node_save($node);
    drupal_set_message('Node saved.');
    $form_state['redirect'] = 'some/path';
  }
}


Or you could just require the checkbox in the form:

$form['mycheckbox'] = [
  // props
  '#required' =&gt; TRUE,
];


If the checkbox is required, the form can't be submitted, and thus the node won't be created.

I would probably require the field(s) instead of silently do nothing on submit if they did not check it. That way the form submit won't get hit and the user won't have to re-enter all of the information.