By gnosis.kv on
As i tested, after a node deletion, drupal always re-direct to the front page.
how can set the redirect destination after deletion in my module for various situation, like for blog, i want to redirect to the user's blog page, for forum i want to redirect to the forum page ...
thanks very much.
Comments
yourmodulename_delete(&$node)
yourmodulename_delete(&$node) {
global $user;
if ($node->type == 'blog') {
drupal_goto("user/". $user->uid ."/blog");
}
if ($node->type == 'forum') {
drupal_goto("forums");
}
}
that's just a guess, I dont use blogs or forums so I have no clue, but the idea will be something like that
thanks danielb. i think the
thanks danielb.
i think the following code should work
Mmmm.... I got the same
Mmmm....
I got the same problem, thanks for the code, but where should I paste this code to?
Where to Paste hook_nodeapi code
You will need to create a custom module. Google 'Drupal custom module' or 'Drupal custom module tutorial'.
There is a problem with that
There is a problem with that code above - if there are any modules that come after the module that has the code above, their delete functions will not be called, and there will be a bunch of data in the system that shouldn't be there. This could cause problems in the future.
I have used something like this:
Since nodes will always be loaded on the front page (with the exception being when there are no nodes on the site after they have been deleted), 'load' will always be called after 'delete', and this process allows for all modules to run their hook_nodeapi with $op == 'delete'.
Contact me to contract me for D7 -> D10/11 migrations.
user 1
this will not work when user 1 wants to delete multiple
however a simple if ($GLOBALS['user']->uid != 1) {
will do the trick.
possible solution ...
Any reason not to do the following right in the forum module ( in drupalroot/modules/forum/forum.module ):
Index: forum.module
===================================================================
--- forum.module (revision 43)
+++ forum.module (revision 71)
@@ -284,6 +284,7 @@
case 'delete':
db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid);
+ drupal_goto("forum/$node->tid");
break;
case 'load':
I did this inside the function forum_nodeapi(), towards the bottom of the function and it seems to do exactly what I need (which is to return the forum user to the forum they were working in after a forum topic delete operation).
I realize this may break after an upgrade and will have to be added back in, so is there any way developers can add the above into the 6.x branch?
Kambiz
Note: The above is an SVN diff, and so the 1 line I added was the drupal_goto() call immediately after the db_query() in the case 'delete' clause, not including the "+" of course.
Which hook is that in?
Which hook is that in?
Contact me to contract me for D7 -> D10/11 migrations.
Never Hack Core
This is a very BAD IDEA. You should never ever hack the core!
http://drupal.org/node/1559728
Old usernames: pc-wurm, Елин Й.
Use the Workflow-ng module
This is very simple to do with the Workflow-ng module. For example, by default the user returns to the front page when they delete a node. The following workflow will redirect to the node parent if the node is part of a book hierarchy.
D7 redirect on node delete