The additional_capabilities_display WordPress PHP filter allows you to control the display of additional capabilities for a user.
Usage
add_filter('additional_capabilities_display', 'your_custom_function', 10, 2); function your_custom_function($enable, $profile_user) { // your custom code here return $enable; }
Parameters
$enable
(bool): Whether to display the capabilities. Default is true.$profile_user
(WP_User): The current WP_User object.
More information
See WordPress Developer Resources: additional_capabilities_display
Examples
Hide Additional Capabilities for All Users
To hide the Additional Capabilities section for all users:
add_filter('additional_capabilities_display', '__return_false');
Hide Additional Capabilities for Specific User Role
To hide the Additional Capabilities section for users with the “editor” role:
add_filter('additional_capabilities_display', 'hide_for_editors', 10, 2); function hide_for_editors($enable, $profile_user) { if (in_array('editor', $profile_user->roles)) { return false; } return $enable; }
Hide Additional Capabilities for Specific User ID
To hide the Additional Capabilities section for a user with the ID 5:
add_filter('additional_capabilities_display', 'hide_for_user_id', 10, 2); function hide_for_user_id($enable, $profile_user) { if ($profile_user->ID == 5) { return false; } return $enable; }
Display Additional Capabilities Only for Administrators
To display the Additional Capabilities section only for users with the “administrator” role:
add_filter('additional_capabilities_display', 'display_for_admins', 10, 2); function display_for_admins($enable, $profile_user) { if (!in_array('administrator', $profile_user->roles)) { return false; } return $enable; }
Display Additional Capabilities Based on Custom Condition
To display the Additional Capabilities section based on a custom condition (e.g., user email domain):
add_filter('additional_capabilities_display', 'display_based_on_email', 10, 2); function display_based_on_email($enable, $profile_user) { $email_domain = '@example.com'; if (strpos($profile_user->user_email, $email_domain) !== false) { return true; } return $enable; }