WordPress.org

Make WordPress Core

Changeset 14110


Ignore:
Timestamp:
04/16/2010 02:54:44 PM (11 years ago)
Author:
nacin
Message:

Allow create_users cap to be used independently of edit_users cap. fixes #12794.

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/menu.php

    r14100 r14110  
    187187    $_wp_real_parent_file['users.php'] = 'profile.php';
    188188    $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
     189    $submenu['profile.php'][10] = array(__('Add New User'), 'create_users', 'user-new.php');
    189190}
    190191
  • trunk/wp-admin/user-new.php

    r14106 r14110  
    4646            $add_user_errors = $user_id;
    4747        } else {
    48             $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
    49             $redirect = 'users.php?usersearch='. urlencode($new_user_login) . '&update=add';
    50             wp_redirect( $redirect . '#user-' . $user_id );
     48            if ( current_user_can('edit_users') ) {
     49                $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
     50                $redirect = 'users.php?usersearch='. urlencode($new_user_login) . '&update=add' . '#user-' . $user_id;
     51            } else {
     52                $redirect = add_query_arg( 'update', 'add', 'user-new.php' );
     53            }
     54            wp_redirect( $redirect );
    5155            die();
    5256        }
     
    111115require_once ('admin-header.php');
    112116
    113 if ( isset($_GET[ 'update' ]) && is_multisite() ) {
    114     switch ( $_GET[ 'update' ] ) {
    115         case "newuserconfimation":
    116             $messages[] = '<div id="message" class="updated"><p>' . __('Invitation email sent to new user. A confirmation link must be clicked before their account is created.') . '</p></div>';
    117             break;
    118         case "add":
    119             $messages[] = '<div id="message" class="updated"><p>' . __('Invitation email sent to user. A confirmation link must be clicked for them to be added to your blog.') . '</p></div>';
    120             break;
    121         case "addnoconfirmation":
    122             $messages[] = '<div id="message" class="updated"><p>' . __('User has been added to your blog.') . '</p></div>';
    123             break;
    124         case "addexisting":
    125             $messages[] = '<div id="message" class="updated"><p>' . __('That user is already a member of this blog.') . '</p></div>';
    126             break;
     117if ( isset($_GET['update']) ) {
     118    $messages = array();
     119    if ( is_multisite() ) {
     120        switch ( $_GET['update'] ) {
     121            case "newuserconfimation":
     122                $messages[] = __('Invitation email sent to new user. A confirmation link must be clicked before their account is created.');
     123                break;
     124            case "add":
     125                $messages[] = __('Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.');
     126                break;
     127            case "addnoconfirmation":
     128                $messages[] = __('User has been added to your site.');
     129                break;
     130            case "addexisting":
     131                $messages[] = __('That user is already a member of this site.');
     132                break;
     133        }
     134    } else {
     135        if ( 'add' == $_GET['update'] )
     136            $messages[] = __('User added.');
    127137    }
    128138}
     
    143153<?php endif;
    144154
    145 if ( ! empty($messages) ) {
     155if ( ! empty( $messages ) ) {
    146156    foreach ( $messages as $msg )
    147         echo $msg;
     157        echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
    148158} ?>
    149159
Note: See TracChangeset for help on using the changeset viewer.