Module works great, but it *always* shows "page not found", even if a node is published *but* the user does not have access to view the node. I believe modifying the module in the following way would only show the "page not found" message if a node is unpublished, but would show "access denied" when a node is published but the user does not have permission to view it:

function unpublished_404_node_page_view($node) {

  // check status, show 404 if unpublished
  if ($node->status == 0) {
    $node_content = MENU_NOT_FOUND;
  }
  // if published, check access
  elseif (!node_access('view', $node)) {
    $node_content = MENU_ACCESS_DENIED;
  }
  else {
    $node_content = node_page_view($node);
  }

  return $node_content;
}

This may not be the best method to do so, but regardless it would be a nice feature...

Comments

butterwise created an issue. See original summary.

butterwise’s picture

Title: Show 'access denied' if published but user does not view permission » Show 'access denied' if published but user does not have view permission
butterwise’s picture

StatusFileSize
new631 bytes

Adding a patch with the aforementioned update.

RAWDESK’s picture

StatusFileSize
new531 bytes

Hi,
Patch at #3 is not completely correct.
If you apply it and view the node as logged in user, you receive a 404 when node is unpublished.
Attached patch fixes this.
Also will this patch cohabitate better with r4032login module, allowing accessed denied to be rerouted to login form.

  • 781a6f0 committed on 7.x-1.x
    Issue #2941746 by butterwise, RAWDESK: Showing access denied for...
captainpants’s picture

Status: Active » Fixed

Thanks for your contribution folks! This issue has been resolved in 7.x-1.2.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.