I am currently developing a D7 site. One content type is a "resource," which is a link to an external site, or uploaded pdf file. I have a page view to list out all resources (/resource-list/edit ) that allows an admin to see resources broken up by category, reorder them, edit, and delete.

The edit, and delete links were added via views. I have also added an "Add new resource" button to the header of the view, which properly opens the add resource form in the admin overlay. However, when the admin submits the new resource, they are redirected to the new node that was created. Instead, I would like them to be redirected back to /resource-list/edit. How would one go about changing the redirect only for this content type, and only when triggered from the /resource-list/edit view page?

3 Answers 3


You can do this with http://drupal.org/project/rules.

Just import this declaration and adjust it to your needs:

{ "rules_redirect" : {
    "LABEL" : "redirect to view",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_insert" ],
    "IF" : [
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "page" : "page" } } } }
    "DO" : [ { "redirect" : { "url" : "path/to/your/view" } } ]
  • Thanks BetaRide! That worked great. The only problem I have now is that there appears to be a rules bug that causes the web server to crash when doing content creation + redirect + using the overlay. Not a big deal as I just disabled the overlay, and hopefully it will be fixed soon.
    – MarkD
    Jun 26, 2012 at 20:33

To redirect using a custom module you can use the following code (Drupal 7):

function MY_MODULE_form_alter($form, &$form_state, $form_id) {

    // drupal_set_message("Form ID is : " . $form_id); // this can be useful to work out the form ID of the form you want to target

    switch($form_id) {

        case 'page_node_form': // here we are making sure that we only add our additional submit handler to the node type we want

            $form['actions']['submit']['#submit'][] = 'custom_submit_handler';

            // dpm($form); // dmp provided by the devel module can be useful for inspecting the $form array



function custom_submit_handler($form, &$form_state) {
    // this will redirect to the front page
    $form_state['redirect'] = '';

If all you want to do is change where a user redirects to after they submit an add node form, there is a much easier way.

Just make your link look like this: /node/add/[CONTENT-TYPE]?destination=[URL-REDIRECT]

Here is an example that I got working: /node/add/ic-competencies-toolkit-codes?destination=admin/survey-codes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.