Skip to content

Instantly share code, notes, and snippets.

@diije
Created June 12, 2013 12:44
Show Gist options
  • Save diije/5764930 to your computer and use it in GitHub Desktop.
Save diije/5764930 to your computer and use it in GitHub Desktop.
WordPress : Modération des commentaires par les Contributeurs
<?php
if ((current_user_can('contributor') || current_user_can('author')) && !current_user_can('moderate_comments'))
add_action('admin_init', 'dfr_moderate_comments');
function dfr_moderate_comments() {
$contributor = get_role('contributor');
$contributor->add_cap('moderate_comments');
$contributor->add_cap('edit_published_posts');
$author = get_role('author');
$author->add_cap('moderate_comments');
}
add_action( 'admin_init', 'dfr_redirect_users' );
function dfr_redirect_users()
{
global $pagenow;
if ($pagenow == "post.php") {
if ( !current_user_can( 'editor' ) ) {
$id = $_GET['post'];
$post = get_post($id);
$current_user = wp_get_current_user();
if ($post->post_status == "publish" && $post->post_author != $current_user->ID)
wp_redirect( admin_url( 'edit.php' ) );
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment