Custom submit handler is also called when deleting a node So these are my functions:

function mycustom_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['actions']['submit']['#submit'][] = 'b2share_form_submit';
  return $form;
}

I can also attach the custom submit handler in other ways to the form, but only this way I can still access the nid and the bundle of the node.

function b2share_form_submit($form, &amp;$form_state, $entity_id, $entity_type) {
   $values = array(
   'url' =&gt; $form_state['values']['b2share_fieldset']['url'],
   'pid' =&gt; $form_state['values']['b2share_fieldset']['pid']
  );

  if ( (empty($values['url'] == false) || (empty($values['pid']) == false)) ) {

    $insert = db_insert('field_data_field_b2share')
      -&gt; fields(array(
       'field_b2share_url' =&gt; $values['url'],
       'field_b2share_pid' =&gt; $values['pid'],
       'entity_id' =&gt; $form_state['node']-&gt;nid,
       'entity_type' =&gt; 'node',
       'bundle' =&gt; $form_state['node']-&gt;type,
       'delta' =&gt; 0,
       'language' =&gt; 'und',
    ))
   -&gt;execute();
 }
}


I can add nodes and edit them perfectly, but whenever I try to delete one, the custom handler function is called and prevent drupal from doing anything. No error messages, nothing in the logs. 

Can someone help?
You made the mistake of giving the form submit function a name that matches the patter form-name_submit. So it does not only trigger by your submit button. It is triggered by every submit button in the form.

Rename your function and you should be good.