giza: Giza White Mage (Default)
[personal profile] giza
So, I'm working on a Drupal site that, for reasons unknown, shows the "create content" menu item even when the user is logged out. Since I don't allow anonymous users to post on this site, clicking on that menu item gives a "permission denied" error. Not exactly the sort of user experience I want to provide.

Well, I just came up with this bit of code to fix the problem. It goes in index.php after the call to drupal_bootstrap():

if (strstr($_SERVER["REQUEST_URI"], "/node/add")) {
   if (empty($user->uid)) {
      drupal_set_message("You must be logged in to do that");
      drupal_goto("user");
   }
}


Share and enjoy! (Or just give me funny looks. That works too.)
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

giza: Giza White Mage (Default)
Douglas Muth

April 2012

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags