laboratorio caffeina

in few words, just developing

 

Restrict authors access to edit comments, the plugin

It's my first wordpress plugin, please be kind ;-)

I've noticed that in wordpress (surely 2.2, not tested on previous, so please tell me if it works) there's no capability separation for editing post and comments (on their post). Even using the Role Manager Plugin.

from wordpress codex:

Manage->Comments -- meaning: "show post"-link; "edit post"-, "edit comment"- and "delete comment"-links only on own posts since edit-comment.php (http://trac.wordpress.org/file/trunk/wp-admin/edit-comments.php) looks for "current_user_can('edit_post', $comment->comment_post_ID)"'

I run a lot of multiple authors blogs and sometimes I need only administrators to edit comments (and I'm not the only one).

So I developed this:

PHP:
  1. <?php
  2. /*
  3. Plugin Name: Restrict author access to edit comments
  4. Plugin URI: http://www.laboratoriocaffeina.it/development/2007/07/20/restrict-authors-access-to-edit-comments-the-plugin.html
  5. Description: Block author access to edit comments, leave it only for admin and editors
  6. Version: 0.3
  7. Author: cedmax
  8. Author URI: http://www.dioblog.it
  9. */
  10.  
  11. function check_user_capabilities() {
  12. global $user_level;
  13.  
  14.   if ( ((strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/edit-comments.php')) or (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/comment.php')))) {
  15.      
  16.      if ($user_level <9){
  17.     echo "<div class='wrap'><h2>Restricted area</h2></div>";
  18.     include('admin-footer.php');
  19.     die();
  20.    
  21.      }
  22.   }
  23. }
  24.  
  25. add_action('init', 'check_user_capabilities');
  26.  
  27. ?>

update
thanks to brad I found out that the direct edit comment link in wordpress points to comments.php and not to edit-comments.php.
so I've changed the script.

update 2
Thanks to Fred (sorry I didn't understand immediatly) and Claus I spotted out another error in version 0.2
Now I've done the v.0.3 changing the hook function: now it works not on the content but on the initialization of the page, so it is not possible for the author to work on comments at all. thanks to everyone :-)

simply download v.0.3, unzip, put the .php file under wp-contents/plugins and activate it from wordpress plugins panel.

 
 
commenti
 
Restrict authors access to edit comments | ????????:

[...] Restrict authors access to edit comments, the plugin | laboratorio caffeina [...]

 
 
Weblog Tools Collection » Blog Archive » WordPress Plugin Releases for 7/21:

[...] Restrict Authors Access to Edit Comments limits comment editing to site administrators. [...]

 
 
Brad:

I have the problem, where authors can edit comments on their posts even though they are not an administrator. I tried out your plugin, and still people can edit comments. Any idea how to fix this?

 
 
cedmax:

You were absolutely right!!!
I’ve changed the plugin, try now and let me know :-)

 
 
vlad:

THe download link isn’t working :(

Please let me know how to use this great plugin. This is awsome :D

Regards from Romania!

 
 
cedmax:

I’m sorry: it’s ok now

 
 
 
 
snowcrash:

Hello

I’m trying out your plugin on wp2.21

Seems to be working nicely

many thanks :-)

 
 
wpSnap Blog » WordPress Plugins for July 2007:

[...] Restrict Authors Access to Edit Comments limits comment editing to site administrators. [...]

 
 
Fred:

Hi, I installed your plugin (thanks, BTW) and it only partially works. When you click on “Comments” in the dashboard, it says “Restricted Area” and that’s good.

BUT, you can still access the comments area by the following:

=>Manage => Posts

There’s a link that takes you right to the “Comments” page. How do I either disable that link, or restrict the page it leads to?????

Thanks in advance for your help.

 
 
cedmax:

I don’t have that link.. which version of wordpress have you got? any plugin installed about post management?

anyway you can disable that page adding

or (strpos($_SERVER['SCRIPT_NAME'], ‘wp-admin/filename.php’))

(where filename.php is the file you want to block) inside the if statement.

do it only if you know what you are doing or contact me: http://www.laboratoriocaffeina.it/contatti

 
 
lee:

is there anyway to let the author level to view/edit their own post comments.

 
 
cedmax:

@lee: I believe that’s the usual wordpress behaviour.
this plugin is to avoid it… or did I misunderstand your question?

 
 
 
The Blog for DesignCreatology » Blog Archive » WP Plugs September 3, 2007:

[...] Restrict Authors Access to Edit Comments limits comment editing to site administrators. [...]

 
 
babbo natale:

THANKS!!

 
 
claus:

Fred: 16 August 2007, ore 15:13

Hi, I installed your plugin (thanks, BTW) and it only partially works. When you click on “Comments” in the dashboard, it says “Restricted Area” and that’s good.

BUT, you can still access the comments area by the following:

=>Manage => Posts

There’s a link that takes you right to the “Comments” page.

He’s right, on the “Comments” column you can see the number of comments to that post. That’s a link, by clicking on it you can still see the comments. I have WordPress 2.2 .

 
 
cedmax:

well, that’s right: the author still cannot edit comments, but he can delete, report as spam or unapprove. I’ll work on it.

thanks

 
 
cedmax:

I’ve done it, thanks for debugging

 
 
claus:

I think Fred’s problem (and mine too) was to hide that link for other authors, so they can’t see the IP addresses and e-mails of the commentators. In the latest version you can’t edit or delete the comments, but you can still see them.
Is there a way to do that, in your opinion? Thanks.

 
 
cedmax:

Surely it’s possible.. but, sadly, now I don’t have enough time now to do enchantments :-(

With the last version of the plugin (0.3) comments are safe from authors actions. and for a while that’s all, sorry.

In the future I’ll work on it, I promise

 
 
Dean:

So that’s it then? There is no way to hide users IPs and email adresses from other users?

How can I tell anyone I WILL NOT publish their personal info when the program hangs it out for the whole world to see?

This is a SERIOUS FLAW that makes the whole package worthless for anyone who lives by his word and implies, “Mail (will not be published) (required)”.

Is WordPress so proud of their dashbord that they won’t let administrators remove the comments and manage links from the Dashboard menus of low level users?

If so they should at least provide a way to strip the IP’s and email addresses out of what is returned by the system.

 
 
cedmax:

it’s not the “world”: it’s who writes on the blog (not subscribers).

wordpress is not a cms: it’s a free blogging software. and my plugin wasn’t meant for privacy, but to avoid authors editing comments in their own post (which is normal wp behaviour).

I don’t understand what are you complaining about.

 
 
bilgiservisim » » En iyi 100 wordpress eklentisi:

[...] 215) Restrict author access to edit comments [...]

 
 
 
art vandelay:

anyway you can disable that page adding
or (strpos($_SERVER[’SCRIPT_NAME’], ‘wp-admin/filename.php’))

I’ve tried to restrict “edit.php” but it didn’t work. My WP version is 2.2.2. Is there any other way to do it?

 
 
Omegacool:

Está chido, aunque un poco burdo, y nececitaría algunas modificaciones, pero cumple con su cometido. Gracias
It chido, albeit a little crude, and would require some modifications, but fulfills its mission. Thanks

 
 
230 Wordpress eklentisi — Wordpress Türkiye:

[...] 207 Restrict author access to edit comments [...]

 
 
Cum sa verifici daca un user de wordpress este administrator | Doua maini:

[...] de a vedea pluginurile, a edita comentarii si a intra in orice pagina din admin daca nu au dreptul Restrict author access to edit comments un plugin simplu, care da un mesaj de eroare atunci cand un user incearca sa accesese pagina [...]

 
 
Brian:

Just wanted to let everyone know there is a way to do this, but it involves hacking the core. There is no way for a plugin to properly do what most of you are wanting. To do so, you need to edit two files (warning, this is for advanced users only):
wp-admin/edit-comments.php
wp-admin/includes/template.php

Find this line in both of them:
if ( current_user_can(’edit_post’, $comment->comment_post_ID) ) {

and move it to the outside of where the loop starts listing comments, so in the edit-comments file it will go before the line:
comment_ID; ?>” class=”>

now for the template.php file, you will be editing the _wp_comment_list_item function and need to MOVE the same line of code to above this line:
echo “comment_ID’ class=’$class’>”;

and in this file you will also need to move the ending bracket “}” to the end of the function. The bracket is located right before this line:
$post = get_post($comment->comment_post_ID, OBJECT, ‘display’);

Just delete the } and put it on the 8th line below so it looks like this:

 
 
Brian:

Ignore the above, the code got messed up

Just wanted to let everyone know there is a way to do this, but it involves hacking the core. There is no way for a plugin to properly do what most of you are wanting. To do so, you need to edit two files (warning, this is for advanced users only):
wp-admin/edit-comments.php
wp-admin/includes/template.php

Find this line in both of them:
if ( current_user_can('edit_post', $comment->comment_post_ID) ) {

and move it to the outside of where the loop starts listing comments, so in the edit-comments file it will go before the line:
comment_ID; ?>" class=''>

now for the template.php file, you will be editing the _wp_comment_list_item function and need to MOVE the same line of code to above this line:
echo "comment_ID' class='$class'>";

and in this file you will also need to move the ending bracket “}” to the end of the function. The bracket is located right before this line:
$post = get_post($comment->comment_post_ID, OBJECT, 'display');

Just delete the } and put it on the 8th line below so it looks like this:

That's it. Check out webunload.com, we have this implemented.

 
 
Brian:

Ah screw it. Sorry.

 
 
Brian:

Sorry for not being able to post a good solution, this blog is acting strangely to the coding. Ignore the previous posts… i can’t edit or delete them.

First part
Search for this line:
$class .= ('unapproved' == $comment_status) ? ' unapproved' : '';

Put this on the next line:
comment_post_ID) ) { ?>

Find this line:
} // end foreach

Put this on the next line:
}

For the second part..
You actually don’t need to edit another file. Instead of needing to edit template.php, you only need to edit the edit-comments.php further. Find this line:
get_comment( $comment ); // Cache it

And put the following on a new line after it:
if ( current_user_can('edit_post', $comment->comment_post_ID) )

There are two places you will need to put the code.

 
 
300 Adet Wordpress Eklentisi : Y?lmaz Eres:

[...] 222 Restrict author access to edit comments [...]

 
 
baron:

hi there.com plugin but :

Does anybody know if tis script is compatible with Wordpress 2.5?

Thanks in advance for any help on this!

turkbaron

 
 
cedmax:

try it and let us know: it won’t break anything

 
 
blog:

perfect document :-) thank you…

 
 
Looking Forward » WordPress and Moderated Comments:

[...] after a lot of research tonight, I’ve come across this plugin which solves the problem in a very inelegant but effective fashion. Now when an author or a [...]

 
 
Wordpress En iyi eklentiler ve aç?klama 400 adet | ?nternet Çöplü?ü:

[...] üye ve arama motoru say?s?n? yan menünüzde görüntüleyebilmenizi sa?lar. 281 © Restrict author access to edit comments Üyelerinizin yetkilerini yönetmenizi [...]

 
 
Forex:

Good document :-) thank you…

 
 
yakup:

Positive comment. thanks you

 
 
word press eklentileri | Grafik Hocam:

[...] 222 Restrict author access to edit comments [...]

 
 
ZDaYLaN.CoM - Fim ?ndir,Oyun ?ndir,Online ?ndirmeden Film ?zle,ZDaYLaN,Daylan,Mardin,Mardin Resimleri,Mardin Yemek Tarifleri,Yemekleri » Aç?klamal? 400 Wordpress Eklentisi - Wordpress:

[...] üye ve arama motoru say?s?n? yan menünüzde görüntüleyebilmenizi sa?lar. 281 © Restrict author access to edit comments Üyelerinizin yetkilerini yönetmenizi [...]

 
 
Aç?klamal? 400 Wordpress Eklentisi:

[...] üye ve arama motoru say?s?n? yan menünüzde görüntüleyebilmenizi sa?lar. 281 © Restrict author access to edit comments Üyelerinizin yetkilerini yönetmenizi [...]

 
 
izle:

thanks you izle..

 
 
 
a?k-? memnu:

thank you. i add you website in my favorites..

 
 
Two more WPMU plugins for K12 | openedweb.com:

[...] were appearing without his having reviewed them and wrote about in his blog. He came up with a plugin that blocks access to the comments [...]

 
 
 
Restrict author access to edit comments - WordPress-TR.NET - WordPress Forumu:

[...] Restrict author access to edit comments a??klama:?yelerinizin yetkilerini y?netmenizi sa?lar Restrict author access to edit comments [...]

 

Commenta



 
Chiudi
E-mail It