Having trouble with how to filter the comment listing from WordPress back-end base on something else like user role? Read this!
Sometime you might have custom role, let’s say co-editor, setup using members plugin in your WordPress. And then you want to achieve showing all comments only to the user who has administrator role but user with co-editor role sees only some of the comment. You could use the below code to overcome this saturation.
function custom_comments_clauses( $pieces ) {
// check role here
if( is_admin() && (!current_user_can( 'administrator' ) ) && current_user_can( 'co_editor' ) ) {
// add your own query here
$pieces['where'] .= " AND comment_post_ID IN ( //add your own query here )";
}
return $pieces;
}
//plug to this filter
add_filter( 'comments_clauses', 'custom_comments_clauses', 10, 1 )
cheap lebron shoes|