Skip to content

Instantly share code, notes, and snippets.

@michaelbrazell
Last active August 29, 2015 14:15
Show Gist options
  • Save michaelbrazell/9afc68f20475625e72a7 to your computer and use it in GitHub Desktop.
Save michaelbrazell/9afc68f20475625e72a7 to your computer and use it in GitHub Desktop.
WP Add author capabilities to moderate comments to
<?php
/* Use this in Functions.php */
function add_publish_caps() {
// gets the contributor role
$role = get_role( 'contributor' );
// Adds capability to moderate comments, edit posts, but not publish posts.
// moderate_comments requires edit_posts which is why we need the remove_cap.
$role->add_cap( 'edit_posts' );
$role->add_cap( 'moderate_comments' );
$role->remove_cap( 'publish_posts' );
}
add_action( 'admin_init', 'add_publish_caps');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment