Plugin Directory

Changeset 3714309


Ignore:
Timestamp:
09/26/2026 01:53:30 PM (4 weeks ago)
Author:
nanosani
Message:

User roles issues fixed.

Location:
itx-userops/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • itx-userops/trunk/itx-userops.php

    r3714287 r3714309  
    44 * Plugin URI:        https://itxuserops.com
    55 * Description:       User management, login activity, sessions & audit log — one unified admin console for WordPress users.
    6  * Version:           2.2.1
     6 * Version:           2.2.2
    77 * Requires at least: 6.6
    88 * Requires PHP:      7.4
    … …  
    1919defined( 'ABSPATH' ) || exit;
    2020
    21 define( 'ITXUO_VERSION', '2.2.1' );
     21define( 'ITXUO_VERSION', '2.2.2' );
    2222define( 'ITXUO_PATH', plugin_dir_path( __FILE__ ) );
    2323define( 'ITXUO_URL', plugin_dir_url( __FILE__ ) );
  • itx-userops/trunk/readme.txt

    r3714287 r3714309  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 2.2.1
     7Stable tag: 2.2.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    218218
    219219== Changelog ==
     220
     221= 2.2.2 =
     222* Fixed: "Duplicate Administrator" was refused with "You cannot grant access you do not have yourself" on most sites. WordPress switches some of the administrator's capabilities off at run time (file editing when DISALLOW_FILE_EDIT is set, the Links manager, unfiltered uploads), and WooCommerce stores per-item ones, and the role editor read all of those as not held. Capabilities your own role grants can now be copied. No other change.
    220223
    221224= 2.2.1 =
    … …  
    271274== Upgrade Notice ==
    272275
     276= 2.2.2 =
     277Fixes "Duplicate Administrator" in the role editor, which was refused on most sites.
     278
    273279= 2.2.1 =
    274280Fixes 2.2.0, which was published without two of its files and stopped sites loading. Update now.
  • itx-userops/trunk/src/Modules/Roles/Writer.php

    r3639234 r3714309  
    162162         * and it already accounts for the network boundary.
    163163         *
     164         * "Hold" includes what the user's own roles grant ON PAPER, and that is what
     165         * made "Duplicate Administrator" work again (2.2.2). WordPress switches some
     166         * capabilities off for everyone at run time — edit_plugins, edit_themes and
     167         * edit_files under DISALLOW_FILE_EDIT, manage_links when the Links manager
     168         * is off, unfiltered_upload unless ALLOW_UNFILTERED_UPLOADS — and WooCommerce
     169         * stores per-item capabilities (edit_product, read_shop_order) that
     170         * current_user_can() can only answer for a specific item. The administrator
     171         * role holds all of them, current_user_can() said no to all of them, and the
     172         * ceiling refused to copy the role it was looking at. Granting what your own
     173         * role already grants cannot lift anyone above you: the same run-time switch
     174         * applies to whoever receives it.
     175         *
    164176         * @param string[] $adding Capabilities about to be granted.
    165177         * @return true|\WP_Error
    … …  
    172184                $refused = array();
    173185
     186                $user = wp_get_current_user();
     187
    174188                foreach ( $adding as $cap ) {
    175                         if ( ! current_user_can( $cap ) ) {
     189                        // On paper first: it answers without asking WordPress to map a
     190                        // per-item capability with no item, which it reports as an error.
     191                        $on_paper = $user instanceof \WP_User && $user->exists() && ! empty( $user->allcaps[ (string) $cap ] );
     192
     193                        if ( ! $on_paper && ! current_user_can( $cap ) ) {
    176194                                $refused[] = $cap;
    177195                        }
Note: See TracChangeset for help on using the changeset viewer.