Hello,
On my site I need to keep comments hidden from other authors and comments hidden from other commenters. The reason being I don't want authors seeing comments on other authors nodes and I don't want commenters being influenced by previous comments. I've nearly accomplished that with the following if condition in my comment.tpl.php file.
<?php
global $user;
?>
<?php if (($comment->uid==$user->uid) || (in_array('author_role', $user->roles))) : ?>
// Code
<?php endif; ?>
As you can see the above code will successfully make comments viewable to only the commenter. But the second OR condition will restrict viewable comments to anyone in the author_role. This won't work since I need only the author of a node to see all of the comments belonging to it.
If anyone out there would be kind enough to help me finish this logic up I would greatly appreciate it.
Comments
I don't believe the node is
I don't believe the node is loaded during comments so you'll need to do something like:
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
Thanks a million WorldFallz it works!
You saved me a lot of hair pulling, thank you.
lol, you're very
lol, you're very welcome.
one thing you might want to keep in mind-- that's going to do a node_load for each comment. If you have lots of comments per node and notice a slowdown, that code might be the culprit (though in general node_loads aren't too bad).
also, it always makes me nervous to do access control in the theme layer, but I can't think of any way around it off the top of my head.
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
Awesome! Thanks for all your
Awesome!
Thanks for all your help and the two caveats. You're the man.
or wo-man, lol. === "Give a
or wo-man, lol.
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
Ha ha
Yeah I didn't look at your profile, my apologies,
You're the woman!
hi, sorry to bring up an old
hi, sorry to bring up an old post, but im trying to do the same,
I tried using this code but dont think its working.
I noticed this is for drupal 5 but im using 6, would this make a difference?
Thanks for any help
You can use $node object
You can use $node object directly in comment.tpl.php
Example:
Also, AFAIK, the arguments for function node_load must be in array, at least in drupal 6
thanks for the help, butstill
thanks for the help, butstill not sure what I should be doing
Hidden Comments
Thanks so much, this seems to be working well. I've tried numerous other ways to acheive the same thing with very limited success, Thanks Grimlock.