How to register Post Submit handler for form? I have a form which I want to modify some of it's data after submission.

I'm using drupal 8.3 and I tried to used hook_form_alter and registered my functions to $form['#submit'][] and $form['actions']['submit']['#submit'][]  but none of them working after form submission.

Any help? Thanks.
I added the following snippet in hook_form_alter:

array_unshift($form['#submit'], 'callback');
foreach ($form['actions'] as $action =&gt; $values) {
    if (isset($form['actions'][$action]['#submit']) &amp;&amp; is_array($form['actions'][$action]['#submit'])) {
        if (!in_array('callback',$form['actions'][$action]['#submit'])) {
            array_unshift($form['actions'][$action]['#submit'], 'callback');
        }
    }
}


This registers to all actions.