Active
Project:
FAQ_Ask
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
30 Apr 2012 at 17:18 UTC
Updated:
24 Mar 2014 at 00:52 UTC
Jump to comment: Most recent
After posting a new question, anonymous users are seeing Access Denied because they are being redirected to the unpublished new node they created. But since they are anonymous, and it is unpublished, they don't have access to it. In drupal 6, they were redirected to the /faq page instead. Can this be fixed to work the way it worked in drupal 6?
Comments
Comment #1
jlea9378 commentedI removed these lines from faq_ask_form_faq_node_form_alter():
and added these lines to faq_ask_submit():
I tested it and it works for anonymous users or users who lack permissions, but the else branch needs work.
$form_state['nid'] isn't right.
Comment #2
stenjo commentedThanks for the update.
$form_state['nid']or$form_state['values']['nid']for that matter does not exist when we are creating a new node. Therefore I have moved some of this to the node_insert hook.The else path is not needed as the form will redirect to itself anyway unless we tell it differently .-)
Comment #3
stenjo commentedI'm really struggeling with the redirect thing. It seems there is something happening in the current code. I have tried a lot of different approaches to making sure the user is redirected to the faq-page if she does not have the access rights to view unpublished nodes, but it seems the redirect field is overwritten at some later stage.
Comment #4
jlea9378 commentedHmm I see what you mean. I put a drupal_set_message in the if statement where the redirect gets set, so it IS getting set, but it is getting overwritten later someplace... because I'm still getting an access denied... I know the code is right for the redirect because it was working before (when the node wasn't getting saved).
Can we use drupal_goto at the end of hook_node_update instead, perhaps?
Comment #5
jlea9378 commentedStill getting "Access denied" in the 5/16/12 dev release.
Comment #6
stenjo commentedAfter posting the question on the issue queue for the core, #1590022: Setting $form_state['redirect'] is ignored I got an answer that I used to implement some changes. Basically, a lot of what was going on in the submit handler is now moved to the hook_node_insert() implementation.
The result is promising and it now seems that users without permission to see unpublished nodes are correctly redirected to the faq-page as of the latest dev release.
Comment #7
jlea9378 commentedLooks good! Thanks!!
Comment #8
stenjo commentedI'll consider this fixed then
Comment #10
Donovan commentedI am seeing this issue with the latest dev version: 7.x-1.0-alpha1+4-dev
Comment #11
Donovan commentedRe-opening this issue as I am seeing it with both the alpha version: 7.x-1.0-alpha1, and the latest dev version: 7.x-1.0-alpha1+4-dev
Comment #12
Donovan commentedFeedback: To get around this problem I implemented a workaround using Rules. It's a simple rule that redirects to faq-page after saving new content type of FAQ.
I hope this is helpful to someone encountering this issue.