By droople on
There are certain roles on my site that can post content.
These roles are Free, Basic, Premium
I would like certain blocks only to show on a node if the node author has a certain role.
I want nodes by Free roles to display all available adverts blocks, nodes by Basic to show one advert block, and nodes by Premium not to show any advert blocks.
Would someone provide me with some php snippet for this.
Thank you
Comments
Something like this in each
Something like this in each block's visibility settings, using PHP input format:
Thank you very much,
I will test this over the next few days and bring back some feedback
cheers
thanks, but how do i show
thanks, but how do i show this on every page not just node pages?
It only makes sense on node
It only makes sense on node pages since it tests against the nodes author.
oh yeah
oh yeah v_v
how can I get the authors role from arguments etc.
like views, user/[uid]/viewname
so if that user is role a display, but if that user is role b dont?
An easier approach
When you configure a block there is a section labeled "Show block for specific roles" where you can select the roles you want to be able to see the block.
nevets, if I understood the
nevets, if I understood the question correctly, everyone should see the same blocks, based on who the author of the node is.
Your right
I missed that part of it being the authors role.
Trying to solve the same problem, but without any success...
I've been trying a lot of variations of the code above from several different posts, but can't get it working to control display of a views block in Drupal 6.10. With this code in the block visibility settings, the block never displays.
I did try similar code in the node.tpl.php file, and it seemed to be finding all the variables.
And, I can control display by node type on the same page with the following code.
But I can't control display by node author using code further above, which I've slightly modified below:
I've tried variations of the above code, but seem to always get FALSE returned.
Any thoughts on how I can approach debugging this?
Other nodes/links that describe the same/similar solutions are:
http://drupal.org/node/273346
http://www.feike.biz/weblog/2008/01/07/drupal-using-node-and-user-inform...
http://drupal.org/node/64135
My mistake. I don't write
My mistake. I don't write much PHP, so sometimes I don't see clearly. Change:
to:
That worked!
Very nice. Yes, that fixed it. Many thanks!
I combined it with showing based on node type to get:
Thank you for a useful
Thank you for a useful code.
But which code should be used if I want certain block only to show on a node if the node author has a certain NAME (not a role)?
I'd be grateful for your help.
You can
You can change
to
and then change
to
Personally, I would stick to the role-based one, I would create an additional special role and assign it to the users. It seems more flexible and logical to me.
Also, since users names can
Also, since users names can be changed the code would be easy to break.
It works! Thank you!
It works! Thank you!
This worked great for
This worked great for mi.
Thanks