For redirecting user to some page after comment submit my below code is working fine :
function my_module_form_alter(&$form, $form_state, $form_id) {
if ($form_id == "comment_node_link_form") {
$form['#submit'][] = 'my_module_submit';
}
}
function my_module_submit($form, &$form_state) {
$form_state['redirect'] = 'newsroom/en';
}
For Comment links I am sending some query string in comment form URL and want to redirect to user to page after comment according to query string value, How can we fetch the query string value to pass it to redirect on hook_submit
http://www.example.com/comment/reply/208943?destination=newsroom#comment-form
http://www.example.com/comment/reply/208943?destination=sections#comment-form
How can we fetch value of destination and pass it to redirect in hook_submit
Please suggest ! Thanks!
UPDATE : I have tried adding hidden field but not able to access it in hook_submit it shows null :
function my_module_form_alter(&$form, $form_state, $form_id) {
if ($form_id == "comment_node_link_form") {
$form['redirect_to'] = array(
'#type' => 'hidden',
'#value' => $_GET['destination'],
);
$form['#submit'][] = 'my_module_submit';
}
}