0

I am building a blog website with many authors. So i have been trying to keep privacy for each author in the back end admin area.

I have been using a nice plugin (https://wordpress.org/plugins/view-own-posts-media-only/) that give to the author only his own posts result in the backend, and also in the edit-comments.php the comments that are related with the authors post only, which is great.

The only problem or malfunction of the plugin is the comments counter in admin area. The plugin is not actually filtering the comments number for author posts criteria.

I have been trying to find some snippet to use just for this reason only. I found this post https://bnks.xyz/showing-an-author-only-their-comments-in-wordpress/ and tried only the comments counter part, but didn't gave me correct results.

Is there any snippet for this problem? How to give to the author the correct counter results, only related to his own posts?

I was trying even if possible to hide just the counter, from the admin with css but i couldn't, as i find the same css also hides other counters. (I don't want to disable the entire comments counter nor to hide the edit-comments.php from author) enter image description here

Any suggestions would be appreciated.

0

For the moment just for hiding the comments counter from an author role, i made a small code like that

 /*
 * Hide Comments Counter for Author Hook
 */
 if ( ! current_user_can( 'manage_options' ) ) { add_filter( 
'comment_status_links', function( $status_links ) 
{

// Override the original links:
$status_links['trash'] = sprintf(
  "<a href=%s>%s <span class='count'></span></a>",
  esc_url( admin_url( 'edit-comments.php?comment_status=trash') ),
  __( 'Trash' )
);
$status_links['spam'] = sprintf(
  "<a href=%s>%s <span class='count'></span></a>",
  esc_url( admin_url( 'edit-comments.php?comment_status=spam') ),
  __( 'Spam' )
);
$status_links['approved'] = sprintf(
  "<a href=%s>%s <span class='count'></span></a>",
  esc_url( admin_url( 'edit-comments.php?comment_status=approved') ),
  __( 'Approved' )
);
$status_links['moderated'] = sprintf(
  "<a href=%s>%s <span class='count'></span></a>",
  esc_url( admin_url( 'edit-comments.php?comment_status=moderated') ),
  __( 'Pending' )
);
$status_links['all'] = sprintf(
  "<a href=%s>%s <span class='count'></span></a>",
  esc_url( admin_url( 'edit-comments.php?comment_status=all') ),
  __( 'All' )
);
return $status_links; 
} ); }


if ( ! current_user_can( 'manage_options' ) ) { add_action('admin_menu', 
'hide_notification_bubble_in_admin_menu'); }

function hide_notification_bubble_in_admin_menu() {
global $menu;
// Override the original links:
$menu[25][0]    = sprintf( __( 'Comments %s' ), '' );
}   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.