Skip to main content
Post Closed as "Opinion-based" by avpaderno
removed "Drupal" and tags from the title
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Customize "Access Denied" (403) page for specific content type in D8?

Source Link
Marcus C.
  • 289
  • 1
  • 13

Customize "Access Denied" (403) page for specific content type in D8?

I'm currently setting up a simple LMS in Drupal 8 and would like to customize the Access Denied page as follows:

  • Anonymous users should be redirected to the Login page, when they hit a 403 error.
  • Logged in users trying to access a specific content type (a Course), which they are not allowed to access, should be redirected to a custom message (telling them to buy the course or something like that). It would be even better, if they could be shown the teaser of that node, but that's not a necessity.
  • In all other cases, I would like to show a general Access Denied page.

Fwiw, there were similiar questions for D6 here and here that also didn't receive any good replies.

Does anybody happen to know a good solution (for D8)? Any help would be much appreciated.