By abramo on
The following works for action:
If UserRole is "X" *AND* UserRole is "Y" then print HELLO WORLD
<?php
global $user;
if ((in_array('X', $user->roles)) && (in_array('Y', $user->roles)))
{
print "HELLO WORLD";
}
?>
but what I need is:
If UserRole is "X" *AND* AuthorRole is "Y" then then print HELLO WORLD
Any ideas?
Many Thanks,
abramo
Comments
Here's something I found for
Here's something I found for getting the author, in chill35's site
http://11heavens.com/taxonomy/term/72
Make sure that a particular node is in the scope of your function, or else author is meaningless. Use $author instead of $user, and then use in_array('Y', $author->roles) in the second case.
many thanks, is this what you mean?
As this stands it does not work, but obviously I have done something wrong?
node_load() needs to be told
node_load() needs to be told which node. Either a nid (number of variable), or an array of conditions like the ones in user_load.
many thanks cog.rusty !!
with your valuable assistance I have resolved this issue !! (please see my post below).
All the best,
abramo
So if the too are in
So if the too are in different roles you want Hello world?
If this is in a node then it should work, GLOBALS being the user viewing the node and the other the author.
thanks, looks promising . . .
but I could not make it work. Yes, this snip goes in a node (via template) and if
is included, it simply does not perform, and if it is not included it returns error:
My current setup functions properly if only the UserRole(s) are required.
Any ideas?
Thanks,
abramo
Here is what has worked for me :)
This is a combination of what cog.rusty and mike.hobo were kind enough to contribute - I have really much appreciated their assistance !! Thanks guys !!
All the best,
abramo
Good. $node is already
Good. $node is already defined if the code is inside node.tpl.php or when you are on a full node page.
Final version . . .
To display content within a node according to User Role AND Author Role - when for example User Role has to be "X" and at the same time Author Role has to be "Y" - use the following snippet in your template for the Content Type in question:
Enjoy!
abramo
Abramo could you help with
this
http://drupal.org/node/379246
thanks