Hello,

I want to redirekt the to userpage after delete a gallery. I test a lot but this did not work for me. Can someone have a look on my rule?
Or is it not possible to do that?

Many thanks for any help!
Frank

{ "rules_delete_a_node_image_gallery_referenced_image_nodes_cloned_" : {
"LABEL" : "Delete a node user image gallery referenced image nodes",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_delete" : [] },
"IF" : [
{ "node_is_of_type" : {
"node" : [ "node" ],
"type" : { "value" : { "node_user_image_gallery" : "node_user_image_gallery" } }
}
}
],
"DO" : [
{ "entity_query" : {
"USING" : {
"type" : "node_gallery_relationship",
"property" : "ngid",
"value" : [ "node" ],
"limit" : "100"
},
"PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
}
},
{ "LOOP" : {
"USING" : { "list" : [ "entity-fetched" ] },
"ITEM" : { "list_item" : "Current list item" },
"DO" : [ { "entity_delete" : { "data" : [ "list-item:nid" ] } } ]
}
},
{ "redirect" : { "url" : "[site:url]user\/[node:author:uid]" } },
{ "drupal_message" : { "message" : "Images [entity-fetched:0] which have been a reference to the deleted gallery were also deleted." } }
]
}
}

Comments

fraweg’s picture

Hello,

can someone give me a tip this is possible and when how to do it ? Many thanks for any help!

Best regards
Frank

fraweg’s picture

... No idea in that issue? :-(

best regards

fraweg’s picture

Was this a stupid question ? Did someone use the redirect funktion with rules?

Best regards
frank

Samfall’s picture

I made a custom module to do something similar. It redirects the user back to the gallery when you delete an image. It also will redirect someone who deletes a book node to that book's parent. It uses the following code as the module:

<?php

/* 
 * implementing hook_form_alter
 */

function delete_redirect_form_alter(&$form,$form_state,$form_id) {
    if ($form_id == 'node_delete_confirm') {
        //add an extra submit function to execute, and make sure it's the last one
        //executed
        if ($form['#node']->type == 'node_gallery_item') {
            if (isset($form['#node']->node_gallery_ref_1)){
                $form['ngid'] = array(
                    '#type' => 'value',
                    '#value' => $form['#node']->node_gallery_ref_1['und'][0]['target_id']
                );
                $form['#submit'][] = 'delete_redirect_image_submit';
            }
        }else{
            if (isset($form['#node']->book['plid'])) {
                $item = $form['#node']->book['plid'];
                $parent = menu_link_load($item);
                // set redirect path value
                $form['rpath'] = array(
                    '#type' => 'value',
                    '#value' => $parent['link_path']
                );
                $form['#submit'][] = 'delete_redirect_submit';
            }
        }
    }
}

/*
 * function called after node is deleted.
 */
function delete_redirect_submit($form, &$form_state){
    if (isset($form_state['values']['rpath'])){
        $form_state['redirect'] = $form_state['values']['rpath'];
    }
}

/*
 * function called after gallery image is deleted.
 */
function delete_redirect_image_submit($form, &$form_state){
    $form_state['redirect'] = 'node/' . $form_state['values']['ngid'];
}
?>

Your question is not stupid. I assume it's easier to change the redirect with a module than with rules. But I've never tried it with rules.