By joedrupal-1 on
I'd like to make whole portions of the site accessible or inaccessible by Role.
I'd most like to accomplish this by limiting the blocks that appear, depending on who is logged in. Clearly this would be easiest to accomplish by Role.
I haven't seen anything in the administration controls that suggests a way to do this.
Is there one?
Comments
I'm possibly halfway there?
I'm working on the same concept but I'm stuck on one thing.
The solution I'm trying is to create individual menus with the menu module. One for each role. I found a lot of information on how to set up blocks so they appear only to certain roles or only when a user is logged in...but I can't find anything that identifies the variable for the menus I've created - so that I can actually PUT the menu in the block.
I know that a block is already created when I create a menu...but I can't figure out how to go in and tweak the block to show/not show.
Wondering if anyone might have a suggestion for finding those variable names?
It seems Drupal is lacking here
I have a similar need here. I would image that a per-node level of permissions would be already built in, but it isnt.
You can kinda do this via the taxonomy-access module, but its rather convoluted, and im not quite sure if it works.
--
eric();
>:-@ | Photography
One way to do it
would be to post php code snippets in a custom block.
To try it, paste the code from this link into a custom block.
To make a custom block, go to admin/block/add -- then, save and enable the block.
This works to show you how to display different content for different users, but I can't imagine it would be that hard to make it work for roles -- just have the "if" statement check for role # as opposed to uid.
Hope this helps.
Cheers,
bonobo
-------
http://www.funnymonkey.com
Tools for Teachers
-------
http://www.funnymonkey.com
Yes but...
What's the variable to call the individualized menu into the block?
I'm not a programmer, but...
I think these two links will start you towards what you need --
http://drupaldocs.org/api/4.6/function/block_example_block
http://drupaldocs.org/api/4.6/function/block_example_contents
I hope this helps.
Cheers,
Bill.
-------
http://www.funnymonkey.com
Tools for Teachers
-------
http://www.funnymonkey.com
Here it is for roles
Thanks Bonobo, you've inspired me. I now use this block body to show my "applications list" only to authenticated users (role number 2). Drupal seems smart enough to not output the block at all if there is no content (that is, the title "Applications" doesn't show up either when you're logged out):
You don't need a loop
You can replace your foreach with:
if (is_array($user->roles) && in_array('Approved Role',$user->roles)) {
Michelle
Maybe it's just me...
Maybe it's just me, but when I enter any such code snippets into a custom block, all it does is echo out the code. It doesn't execute any of the php statements. It just returns the code as text.
(running Drupal 4.6.4)
I also tried it with return statements. Nothing seems to cause it to evaluate as php.
Oh... and yes, I had the
Oh... and yes, I had the input format set to allow php. : )
patch for 4.6 block.module for this, real solution coming in 4.7
i wrote a patch to the 4.6 version of block.module that allows site admins to just select via checkboxes what roles should be able to view any given block. see http://drupal.org/node/49154 for details. also, this functionality will be added to 4.7 sometime soon (see http://drupal.org/node/18018 for info on that discussion).
___________________
3281d Consulting
Thank you for the patch
Just what I needed
Thel