Skip to content

Instantly share code, notes, and snippets.

@scribu
Created June 28, 2011 22:24
Show Gist options
  • Save scribu/1052398 to your computer and use it in GitHub Desktop.
Save scribu/1052398 to your computer and use it in GitHub Desktop.
Restrict comment editing
<?php
// http://scribu.net/wordpress/prevent-blog-authors-from-editing-comments.html
function restrict_comment_editing( $caps, $cap, $user_id, $args ) {
if ( 'edit_comment' == $cap ) {
$comment = get_comment( $args[0] );
if ( $comment->user_id != $user_id )
$caps[] = 'moderate_comments';
}
return $caps;
}
add_filter( 'map_meta_cap', 'restrict_comment_editing', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment