If you use modules like Ubercart or Drupal Commerce, you already have Rules module enabled.
I'm not personally a fan of Rules module due to difficulties in migrating content and because the module is heavy to accomplish a few tasks.
You have few hooks you can implement.
hook_node_insert
/update
`: Executes on all node insert and update events, even the programmatic ones. Do NOT call drupal_goto() in such hook because it can break a lot of things and the remaining hooks will not run.
hook_form_alter
: Go for this! Better yet you can improve the number of hook calls if you implement hook_form_node_form_alter
(hook_form_BASE_FORM_ID_alter
). You can check the node type inside the hook. If you implement hook_form_alter
, make sure you validate the $form_id
.
While in the form alter hook, add your custom submit handler, which can then set the form redirect destination and display the message.
<?php
function MYMODULE_form_node_form_alter(&$form, &$form_state) {
// Validate node type and other conditions here.
$form['#submit'][] = 'MYMODULE_SOME_APPROPRIATE_FUNCTION_NAME';
}
function MYMODULE_SOME_APPROPRIATE_FUNCTION_NAME($form, &$form_state) {
$form_state['redirect'] = 'somewhere/you/want/to/redirect';
drupal_set_message(t('Some message you want to display'));
}