<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[14110] trunk/wp-admin:
Allow create_users cap to be used independently of edit_users cap.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14110">14110</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-04-16 14:54:44 +0000 (Fri, 16 Apr 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Allow create_users cap to be used independently of edit_users cap. fixes <a href="http://trac.wordpress.org/ticket/12794">#12794</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminmenuphp">trunk/wp-admin/menu.php</a></li>
<li><a href="#trunkwpadminusernewphp">trunk/wp-admin/user-new.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/menu.php (14109 => 14110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/menu.php        2010-04-16 14:15:16 UTC (rev 14109)
+++ trunk/wp-admin/menu.php        2010-04-16 14:54:44 UTC (rev 14110)
</span><span class="lines">@@ -186,6 +186,7 @@
</span><span class="cx"> } else {
</span><span class="cx">         $_wp_real_parent_file['users.php'] = 'profile.php';
</span><span class="cx">         $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
</span><ins>+        $submenu['profile.php'][10] = array(__('Add New User'), 'create_users', 'user-new.php');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $menu[75] = array( __('Tools'), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'div' );
</span></span></pre></div>
<a id="trunkwpadminusernewphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/user-new.php (14109 => 14110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/user-new.php        2010-04-16 14:15:16 UTC (rev 14109)
+++ trunk/wp-admin/user-new.php        2010-04-16 14:54:44 UTC (rev 14110)
</span><span class="lines">@@ -45,9 +45,13 @@
</span><span class="cx">                 if ( is_wp_error( $user_id ) ) {
</span><span class="cx">                         $add_user_errors = $user_id;
</span><span class="cx">                 } else {
</span><del>-                        $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
-                        $redirect = 'users.php?usersearch='. urlencode($new_user_login) . '&update=add';
-                        wp_redirect( $redirect . '#user-' . $user_id );
</del><ins>+                        if ( current_user_can('edit_users') ) {
+                                $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
+                                $redirect = 'users.php?usersearch='. urlencode($new_user_login) . '&update=add' . '#user-' . $user_id;
+                        } else {
+                                $redirect = add_query_arg( 'update', 'add', 'user-new.php' );
+                        }
+                        wp_redirect( $redirect );
</ins><span class="cx">                         die();
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="lines">@@ -110,20 +114,26 @@
</span><span class="cx">
</span><span class="cx"> require_once ('admin-header.php');
</span><span class="cx">
</span><del>-if ( isset($_GET[ 'update' ]) && is_multisite() ) {
-        switch ( $_GET[ 'update' ] ) {
-                case "newuserconfimation":
-                        $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>';
-                        break;
-                case "add":
-                        $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>';
-                        break;
-                case "addnoconfirmation":
-                        $messages[] = '<div id="message" class="updated"><p>' . __('User has been added to your blog.') . '</p></div>';
-                        break;
-                case "addexisting":
-                        $messages[] = '<div id="message" class="updated"><p>' . __('That user is already a member of this blog.') . '</p></div>';
-                        break;
</del><ins>+if ( isset($_GET['update']) ) {
+        $messages = array();
+        if ( is_multisite() ) {
+                switch ( $_GET['update'] ) {
+                        case "newuserconfimation":
+                                $messages[] = __('Invitation email sent to new user. A confirmation link must be clicked before their account is created.');
+                                break;
+                        case "add":
+                                $messages[] = __('Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.');
+                                break;
+                        case "addnoconfirmation":
+                                $messages[] = __('User has been added to your site.');
+                                break;
+                        case "addexisting":
+                                $messages[] = __('That user is already a member of this site.');
+                                break;
+                }
+        } else {
+                if ( 'add' == $_GET['update'] )
+                        $messages[] = __('User added.');
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> ?>
</span><span class="lines">@@ -142,9 +152,9 @@
</span><span class="cx">         </div>
</span><span class="cx"> <?php endif;
</span><span class="cx">
</span><del>-if ( ! empty($messages) ) {
</del><ins>+if ( ! empty( $messages ) ) {
</ins><span class="cx">         foreach ( $messages as $msg )
</span><del>-                echo $msg;
</del><ins>+                echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
</ins><span class="cx"> } ?>
</span><span class="cx">
</span><span class="cx"> <?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?>
</span></span></pre>
</div>
</div>
</body>
</html>