I have tried to search for solution to this for quite a while now.
I am writing a D7 version of the FAQ Ask module and are stuck on the issue where I'm trying to redirect users to a custom page after posting a node creation form.
The module allows users (both anonymous and registered) with the ask question and create faq content permissions to create an unpublished node with a title and a custom field set - but not the body field. These users are not allowed to view the unpublished node, but should be redirected to a custom page when posting a question.
Regardless it seems of what I set the redirect attribute of the $form_state to, the user is redirected to the 'node/[nid]' of the newly created (but unpublished) node resulting in a Access Denied error displayed.
See further details in the issue #1554912: Access Denied for Anonymous comment #3 detailing the code where this is handled.
I can see that even if I set $form_state['redirect'] = array('faq-page'); // Redirect to faq-page if the user is not allowed to view content when I evaluate what is happening in drupal_redirect_form(), then the redirect path is set back to 'node/[nid]' again.
So, somewhere between my faq_ask_submit($form, &$form_state) implementation and drupal_redirect_form() call, the $form_state['redirect'] is overwritten to e.g. 'node/432'.
I have written my own submit handler that is added to the form in my hook_form_FORM_ID_alter(&$form, &$form_state):
$form['#submit'][] = 'faq_ask_submit';
Anyone have any clue to what is going on?
Comments
is the alpha version of the code having this issue
So I can download the code and look at it?
I tried dev and alpha
I gave anon users the 'ask question' permission, then logged out, I can't ever get the ask form for anon users, I always get access denied.
Try hook_node_insert()
Just a quick thought, you might try hook_node_insert().
I haven't fully tested this out, but in D6 I used hook_nodeapi with code like below. Something similar might work in D7.
fast women, pretty cars, sexy computers
https://coderwall.com/algorgeous/