By miggidy on
I've fiddled around with the access control panel and unchecked everything for anonymous users. Basically, I don't want the anonymous user to see anything except "You're not authorized" , my logo and a sign-in box.
My problems started when I added some items to the Navigation menu - and created a new menu tree which I added as a block. Now anonymous users can see one random item in the main nav menu, and the header, but nothing else, in the new block.
Any idea how I limit access to those blocks given that every single thing is unchecked for anonymous users in the access control menu.
Comments
You could try to use the
You could look at the front page module,
Are you sure about this?
Are you sure about this? search engine crawlers won't be able to index your site, only this page and the login ones.
One way to do this is to modify your theme adding a conditional php code to test for anonymous users. Check the code php snippets for ideas.
A snippet that may help you:
Show block to certain users or roles only
--
Webmaster Resources | Canadian Directory
Completely sure
Yeah, it's a corporate intranet - less people see it the better :) Thanks for the links, but what I need is a way of editting non-custom blocks -that is, blocks defined by Drupal like the navigation menu or a menu I've created.
4.7 has this out of the box
If you edit the settings for a block (admin-->block, then "configure" for each individual block) you can determine block visibility through php snippets -- if the snippet evaluates to true, the block is displayed.
Hope this helps.
Cheers,
Bill
-------
http://www.funnymonkey.com
Tools for Teachers
-------
http://www.funnymonkey.com
RE: How do I turn off certain blocks for anonymous users?
I am currently in the same situation as you, but I need a way to have menus, not blocks that are only accessible to specific user roles
Anyways, below is the php block code for your situation. It supports multiple user roles and includes three sample menu items. Only the user roles, Employees, Engineering, and Sales, shown in the example code below, can view this block only after they have logged in.
Just modify the code for your needs.
Form my situation....
Ideally, I would like to have an "Internal Affairs" Menu block that is only visible to the Employees, Engineering, and / or Sales user roles, but.... also be able to simply add menu items for the node pages as easily as you can with the regular menus within the Drupal website.
What is the best way to achieve this goal?
Please help if you can.
Sam Raheb (Sam308)
The best I could come up with
Is to make several custom menu's using the menu.module (a core module) with easy titles eg Sales, Engineering
Then make a block:
Of course, you may want to include some in_array checks eg to check that Sales is indeed in the mid_by_title array.
To check for multiple roles at once, use count(array_intersect())>0.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
Useful...
Where do I put this code?
In a custom block
You can put the code in a custom block; make sure to set it to php. The drawback of this approach is that the title of the block is fixed.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.