In some cases it would make sense to have different text depending on
- whether the user is logged in.
- if logged in, which roles does he have.
- which roles are missing to see the page.

For instance:
"Only logged-in users can see this page. Click here to create an account."
"This page is only visible to users who have verified their address. Click here to do this." (and gain the "verified" role)

Comments

donquixote’s picture

Title: Different 404 pages per user role. » Different 403 pages per user role.

Issue is about 403 (access denied), not 404.

gisle’s picture

Status: Active » Closed (won't fix)

Thanks for the suggestion. However adding this type of functionality is beyond the scope of this basic module. Since this feature request hasn't moved in two years, it is now dropped from the issue queue.

kcannick’s picture

I've been looking for this same functionality for over a year.

I have a site with 3 levels of membership
authenticated users, basic members and premium members. I can control access with TAC but cannot for the life of me figure out how to show an informative message upon 403.

examples:
"You must be Registered to access this page." for pages requiring authenticated user role
"Basic Membership required... Click Here to Upgrade" for pages requiring "Basic" user role
"Premium Membership required... Click Here to Upgrade" for pages requiring "Premium" user role

mlncn’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Issue summary: View changes
Status: Closed (won't fix) » Needs review
StatusFileSize
new557 bytes

Proposing a compromise to this feature request!

The original example, providing an alternate 403 error message to authenticated users versus anonymous users, has been implemented in this module building on Custom Error: https://www.drupal.org/sandbox/mlncn/customerroralt

The catch is it needs the attached three-line patch in order to work. It allows customerroralt to provide an alternate 'code' for just the last three steps which use the code in variable_get() commands. This is after the real code has already been provided to the headers sent by Drupal.

I'd be happy to contribute customerroralt as a submodule for customerror or as a separate project, and to accept patches there to provide a custom error page title and message per role.

  • gisle committed 2a98cef on 7.x-1.x authored by mlncn
    Issue #1030434 by mlncn: Added code to interface to customerroralt...
gisle’s picture

Title: Different 403 pages per user role. » Show different 403 pages per user role.

Thanks for the patch mlncn! It has now been commited to the 7.x-1.x dev branch. I'll push it as a regular release as soon as a third user reviews it and gives it status RTBC.

I am happy to accept customerroralt as a submodule for customerror. However, I am not the project owner, so I cannot grant you co-maintainer status, which means that you shall not be able to maintain it directly.

You may ask the owner (kbahey) to be made a co-maintainer of customerror, or you may want to set it up as a separate project.

mlncn’s picture

Awesome, thank you!

Yes, i would like customerroralt to be taken as a submodule. Would you like me to create a patch with it?

I'd accept co-maintainership to help out with this and other aspects (such as #2339349: Do not show PHP checkboxes unless PHP Filter module is enabled!) but am not seeking it. Thanks!

gisle’s picture

No need to create a patch, I have the sub-module already. It will be include it in the next nightly release.

  • gisle committed 5be869f on 7.x-1.x authored by mlncn
    Issue #1030434 by mlncn: Added submodule: Custom error alternate for...

  • gisle committed e6c6995 on 7.x-1.x
    Issue #1030434 by gisle: Added weights for: Custom error alternate for...

  • gisle committed d431b1d on 7.x-1.x
    Issue #1030434 by gisle: Removed redundant checkboxes for enabling PHP...
mlncn’s picture

Gisle, you rock. Thank you.

gisle’s picture

Version: 7.x-1.x-dev » 7.x-1.3
Status: Needs review » Fixed

Fixed in release 7.x-1.3.

Status: Fixed » Closed (fixed)

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