How do I alter the submit function?
Here am altering the submit handler of the article content type while creating new article type contents 

  /**
     * Implements hook_form_alter().
     */
    function example_module_form_alter(&amp;$form, FormStateInterface $form_state,$form_id) {
   // dsm($form_id);

      switch ($form_id) {

        case 'node_article_form':      // New article nodes.
        // Attach our custom submit handler.
     array_unshift( $form['actions']['publish']['#submit'], 'example_module_node_article_form_submit');
          break;

      }

    }

    function example_module_node_article_form_submit($form, FormStateInterface $form_state) {
      drupal_set_message('custom submit ...');
    }


Source