I can redirect user after adding a node to any another page but would like to redirect them to previous page they were linked from. Now I use the following code:
function user_add_node_form_foto_node_form_alter(&$form, &$form_state, $form_id) {
$form['actions']['submit']['#submit'][] = 'user_add_node_foto_node_form_submit';
}
function user_add_node_foto_node_form_submit($form, &$form_state) {
$form_state['redirect'] = 'node/add/foto';
}
How can I change a code to redirect users to previous page after submitting the form?
EDIT: Every foto node type has a node reference field "field_relate_to_gallery". By using this I created a gallery in Views and added a link "Add foto in gallery" on gallery page linking to add node form. I would like returning users back to gallery after adding a node "foto". That means that a have a lot of galleries with different ID and a cannot redirect the this form only to one particular gallery.
My Solution If someone is interested in. I did it by using node reference from url module. Now my user can add an image from gallery page (there is a link to add node form) and after submitting it he returnes to the gallery page.