From bbdd9fb4a9b2079459e5a7e7d4374b728bfca866 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Wed, 26 Feb 2025 23:48:24 +0000 Subject: [PATCH] Comments: Remove bulk action dropdown depending on user caps. This changeset adds a conditional to show the comments bulk actions dropdown only when the current user has `moderate_comments` capability. Props snicco, iflairwebtechnologies, shanemuir, audrasjb. Fixes #59440. git-svn-id: https://develop.svn.wordpress.org/trunk@59877 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-comments-list-table.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index e7707daba9..c4d323cf89 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -357,6 +357,10 @@ class WP_Comments_List_Table extends WP_List_Table { protected function get_bulk_actions() { global $comment_status; + if ( ! current_user_can( 'moderate_comments' ) ) { + return array(); // Return an empty array if the user doesn't have permission + } + $actions = array(); if ( in_array( $comment_status, array( 'all', 'approved' ), true ) ) {