Skip to content

Instantly share code, notes, and snippets.

@jimihenrik
Last active January 31, 2017 21:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimihenrik/afe9fbea88133442e530 to your computer and use it in GitHub Desktop.
Save jimihenrik/afe9fbea88133442e530 to your computer and use it in GitHub Desktop.
// Disallow comment moderation
function block_bulk_comments_actions($actions) {
unset($actions['unapprove']);
unset($actions['approve']);
unset($actions['spam']);
unset($actions['trash']);
return $actions;
}
function block_comment_row_actions($actions, $comment) {
unset($actions['reply']);
unset($actions['approve']);
unset($actions['unapprove']);
if($comment->user_id != get_current_user_id()) {
unset($actions['quickedit']);
unset($actions['edit']);
unset($actions['trash']);
}
unset($actions['spam']);
return $actions;
}
if (!current_user_can('moderate_comments')) {
add_filter('bulk_actions-edit-comments', 'block_bulk_comments_actions');
add_filter('comment_row_actions', 'block_comment_row_actions', 10, 2);
}
function UM_no_comment_moderation() {
global $pagenow;
if (!current_user_can('moderate_comments') && $pagenow == 'comment.php') {
if(get_current_user_id() != get_comment($_GET['c'])->user_id) {
wp_redirect(home_url().'/wp-admin/edit-comments.php'); exit;
}
}
}
add_action('admin_init', 'no_comment_moderation');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment