I have Druapl 6 with orgranic groups installed. I need a thing - when a group user creates "group" content after node form submission he must be redirected back on group homepage instead of node view page.
function heihachi_form_alter(&$form, $form_state, $form_id) {
switch($form_id) {
case 'group_wall_node_form':
unset($form['buttons']['preview']);
$redirect = 'node/' . $form['og_initial_groups']['#value'][0];
$form_state['redirect'][0] = $redirect;
//dpm($form);
break;
}
}
but that code doesn't redirect at all. Using simple $form['#redirect'] works, but it affects Node delete button aswell, so i can't delete my node because it redirects on a custom path. Thanks for all advices in advance.
My new code (not working also):
function heihachi_form_alter(&$form, $form_state, $form_id) {
switch($form_id) {
case 'group_wall_node_form':
unset($form['buttons']['preview']);
$form['#submit'][] = 'custom_redirect';
//dpm($form);
break;
}
}
function custom_redirect($form, &$form_state) {
//unset($_REQUEST['destination']);
//unset($form['#redirect']);
$form_state['rebuild'] = TRUE;
$redirect = 'node/' . $form['og_initial_groups']['#value'][0];
$form_state['redirect'] = $redirect;
}
This is what i see in $form variable:
0 (String, 21 characters ) menu_node_form_submit | (Callback) menu_node_form_submit();
1 (String, 31 characters ) auto_nodetitle_node_form_submit | (Callback) auto_nodetitle_node_form_submit();
2 (String, 15 characters ) custom_redirect | (Callback) custom_redirect();
I guess something wrong is there?
SOLVED!
used hook_nodeapi as one guy told me below:
function heihachi_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
if ($node->type == 'group_wall') {
if ($op == 'insert') {
$_REQUEST['destination'] = 'xxx';
}
}
$form_state['redirect'] = $redirect;
trydrupal_goto
incustom_redirect
function. – Sumit Madan Dec 13 '12 at 4:04