WordPress.org

Make WordPress Core

Ticket #16501: 16501.2.diff

File 16501.2.diff, 3.5 KB (added by nacin, 7 years ago)
  • wp-admin/users.php

     
    4848case 'promote':
    4949        check_admin_referer('bulk-users');
    5050
     51        if ( ! current_user_can( 'promote_users' ) )
     52                wp_die( __( 'You can’t edit that user.' ) );
     53
    5154        if ( empty($_REQUEST['users']) ) {
    5255                wp_redirect($redirect);
    5356                exit();
     
    352355echo esc_html( $title );
    353356if ( current_user_can( 'create_users' ) ) { ?>
    354357        <a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
    355 <?php } elseif ( current_user_can( 'promote_users' ) ) { ?>
     358<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
    356359        <a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
    357360<?php }
    358361
  • wp-admin/includes/class-wp-users-list-table.php

     
    132132        function extra_tablenav( $which ) {
    133133                if ( 'top' != $which )
    134134                        return;
     135                if ( ! current_user_can( 'promote_users' ) )
     136                        return;
    135137?>
    136138        <div class="alignleft actions">
    137139                <label class="screen-reader-text" for="new_role"><?php _e( 'Change role to&hellip;' ) ?></label>
  • wp-admin/user-new.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once('./admin.php');
    1111
    12 if ( ! current_user_can('create_users') && ! current_user_can('promote_users') )
    13         wp_die(__('Cheatin&#8217; uh?'));
     12if ( is_multisite() ) {
     13        if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) )
     14                wp_die( __( 'Cheatin&#8217; uh?' ) );
     15} elseif ( ! current_user_can( 'create_users' ) ) {
     16        wp_die( __( 'Cheatin&#8217; uh?' ) );
     17}
    1418
    1519if ( is_multisite() ) {
    1620        function admin_created_user_email( $text ) {
  • wp-admin/menu.php

     
    191191if ( current_user_can('list_users') ) {
    192192        $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
    193193        $submenu['users.php'][5] = array(__('Users'), 'list_users', 'users.php');
    194         $submenu['users.php'][10] = array(_x('Add New', 'user'), 'promote_users', 'user-new.php');
     194        if ( current_user_can('create_users') )
     195                $submenu['users.php'][10] = array(_x('Add New', 'user'), 'create_users', 'user-new.php');
     196        else
     197                $submenu['users.php'][10] = array(_x('Add New', 'user'), 'promote_users', 'user-new.php');
    195198
    196199        $submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php');
    197200} else {
    198201        $_wp_real_parent_file['users.php'] = 'profile.php';
    199202        $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
    200         $submenu['profile.php'][10] = array(__('Add New User'), 'promote_users', 'user-new.php');
     203        if ( current_user_can('create_users') )
     204                $submenu['profile.php'][10] = array(__('Add New User'), 'create_users', 'user-new.php');
     205        else
     206                $submenu['profile.php'][10] = array(__('Add New User'), 'promote_users', 'user-new.php');
    201207}
    202208
    203209$menu[75] = array( __('Tools'), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'div' );