HI all,

I'd like a particular content type (or all the content if really need be) to be restricted to just authenticated users. IE you have to sign up to be able to consume the content.

The big problem for me is the Access Denied! You are not authorized to view this page!" message that shows on nodes (like on index pages and when you try to view the node). It's horrible, and really pretty off putting.

Is there a way to configure Drupal so that instead of this harsh message, users could get a nice, polite message askign them to sign up in order to view content?

Any ideas most appreciated, thanks!

Comments

dasithds’s picture

just go to admin->site configuration->error reporting....

you can change the page that is displayed for 403(access denied) and 404(page not found) errors, so just create a seperate page saying "login or register to access this area" and specify the link to that page.

Best Regards,
Dasith.

http://www.mytechdaily.com

Nick Wilson’s picture

You'd certainly think that would work wouldn't you?

I have configured the site so only authenticated users can view content, and have set the default 403 to a custom page but these things still happen:

  • User is NOT redirected to the custom 403 (is this because they are not allowed to view content?)
  • Teaser pages still show the node titles and teasers even though you shouldnt be able to view content

Any more thoughts Dasith?

thanks for the help

pete-drupal’s picture

Note: the following approach is global to the site and as far as I know cannot be restricted to some content types.

Not sure this applies 100% to your case, but this works for me (all the steps done as admin user):

  1. Install and enable the module Front Page
  2. Go to Home » Administer » Site configuration » Advanced front page settings
  3. Under field group "Front Page for anonymous user", set the following:
  • Body (just an example, feel free to modify as appropriate in your context):
    <p>This site is accessible to authenticated users only.</p>
    
    <p>Please login first.</p>
    
  • Select type:
    Themed
  • Redirect to:
    Should not be applicable, but I left the default "node"
  • Under field group "Front Page for authenticated user", set the following:
    • Body: not used (in this example)
    • Select type:
      Redirect
    • Redirect to:
      Set the page that should be visible to authenticated users, eg: "node"
  • Define the frontpage for all your remaining roles...
  • Save configuration
  • Now, an anonymous user sees: "This site is accessible to authenticated users only. Please login first", and an authenticated user sees the standard node page.

    pete-drupal’s picture

    Forgot to mention: the solution I just suggested was tested under Drupal 5.7 (there is a Drupal 6 version of the module Front Page, but I didn't test it)

    dasithds’s picture

    Hi I didnt checkout the frontpage module but i tested out whether the error reporting actually worked.... what I did was created a page and then set it as the default error page for both 403 and 404 errors..... then via site admin I denied permission for guests to access content.... have a look....
    http://www.mytechdaily.com... it blocks everything...no sweat:)

    btw im not sure about how this works in D6... this is for D5.7....

    http://www.mytechdaily.com

    Nick Wilson’s picture

    Yeh, I'm using D6 guys..

    Front Page looks very cool. But if a user had a link to an internal page it wouldnt block them right? In D6, having the error page as /403 is not working at all..

    Sheesh, I may have to downgrad to 5.7.......

    thanks again

    dasithds’s picture

    Nick you need to create a new page that will display the message via create content->page

    then get the link which leads to that page..... then in the error reporting section link that page for cases of 403 errors

    say you create a page which has a link say http://drupal.org/node/xxx.... you have to go to the error reporting section and add node/xxx in the box to completely specify the alternate page that should be displayed for 403 errors....

    /403 doesnt work because you dont have such a page created....

    http://www.mytechdaily.com

    Nick Wilson’s picture

    Ah but it does :)

    Because that's the url alias i gave it! hehe..