hook_form_alter help (almost there!) There are two parts of a third-party module that I am trying to alter.


When the user clicks submit 
When the user clicks reset


This is the function from that module.

function linkedin_user_settings_form($form, &amp;$form_state, $account) {
  // Just fetch forms from submodules.
  $form['linkedin']['elements'] = module_invoke_all('linkedin_user_settings_page', $account);
  // We will need the account at submit
  $form['#account'] = $account;

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Save',
  );
  $form['linkedin']['reset'] = array(
    '#type' =&gt; 'submit',
    '#description' =&gt; t('Click here to unlink your LinkedIn account.'),
    '#value' =&gt; t('Unlink'),
  );

  return $form;
}


This is the code in my module.

function my_module_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'linkedin_user_settings_form') {
    $form['#submit'][] = 'my_module_form_submit';
  }
}

function my_module_form_submit($form,$form_state) {
  // on submit do this
  drupal_set_message(t('You Saved'));

  // on reset do this
  drupal_set_message(t('You Reset'));
}


How can I check which button on the form has been clicked from the users?
You should be able to just copy what that linkedin code is doing in it's own linkedin_user_settings_form_submit submit function: 

$op = $form_state['values']['op'];
if ($op == $form['linkedin']['reset']['#value']) {
 drupal_set_message(t('LinkedIn preferences have been reset'));
} else {
  drupal_set_message(t('LinkedIn preferences have been saved'));
}