Make WordPress Core

Changes between Version 2 and Version 3 of Ticket #43936, comment 69


Ignore:
Timestamp:
04/28/2025 10:58:13 AM (8 weeks ago)
Author:
SirLouen
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #43936, comment 69

    v2 v3  
    37371. More than limiting by roles, as @davidbaumwald suggests, the important thing here is to limit by capabilities, for example, if a role has `manage_options` it should not be able to be assigned by default. Refer to [https://wordpress.org/documentation/article/roles-and-capabilities/ Roles and Capabilities] for more information.
    3838
    39 2. Although, on the other side, the problem with referring to capabilities, is that, if tomorrow, there is a very relevant and "dangerous for any malicious attacker" capability released, who will remember to include this? ~~I have not gone deep in the code~~, but I wonder if there is a "pack" of capabilities by levels, somewhere in the code (for example, array of administrator default capabilities). In that case, just by doing an `array_intersect` between the Custom Role and the Admin Role and in case the result is not empty, then add this role to the list of hindered roles. **EDIT**: I've been doing a little research and appears that you can get an array of capabilities per role in `wp_roles()->roles`, as the value `capabilities` of the key administrator and consequently, you can get other roles and intersect with ease.
     392. Although, on the other side, the problem with referring to capabilities, is that, if tomorrow, there is a very relevant and "dangerous for any malicious attacker" capability released, who will remember to include this? ~~I have not gone deep in the code~~, but I wonder if there is a "pack" of capabilities by levels, somewhere in the code (for example, array of administrator default capabilities). In that case, just by doing an `array_intersect` between the Custom Role and the Admin Role and in case the result is not empty, then add this role to the list of hindered roles. **EDIT**: I've been doing a little research and appears that you can get an array of capabilities per role in `wp_roles()->roles`, as the value `capabilities` of the key administrator and consequently, you can get other roles and intersect with ease. **EDIT 2:** I forgot that administrator capabilities include all caps, not only admin ones. So before this we should get which are the admin caps by making an `array_diff` between the two chosen ones (Author and Admin, or Editor and Admin).
    4040
    41413. As I said, which are the testing steps to reproduce the Health Check if the Admin is removed by default?