Drupal: changing values on submit for node/page form

It’s a pretty simple thing, but just in case there is anybody out there as dumb as me this might be helpful. It’s confusing too because on drupal.org everybody is talking about doing it like $form[‘#submit’][] = ‘my_custom_submit_handler’, which just doesn’t work for the node edit form.

If you are trying to add a button to the page edit form and you want it to change some of the values in the form before submitting it properly, you need to do it like this:

* Implementation of hook_form().
function mymodule_form_page_node_form_alter(&$form, &$form_state) {
$form['buttons']['Change a taxonomy value and save'] = Array (
'#type' => 'submit',
'#value' => t('Change a taxonomy value and save'),
'#weight' => 4,
'#submit' => Array('_mymodule_change_page_taxonomy_value_submit', 'node_form_submit')

* Function to perform changes to the workflow status field etc once page is saved
function _mymodule_change_page_taxonomy_value_submit($form, &$form_state) {
// Change the taxonomy value to whatever it is meant to be
$mynewtaxonomyvalue = [taxonomyobjectfromsomewhere];
$form_state['values']['taxonomy'][5] = $mynewtaxonomyvalue->tid;