Add additional promote_users checks. Show Add existing button only for multisite. Don't show bulk actions if user can't promote users. Show add new user menu if user has create_users but not promote_users. Props nacin. fixes #16501 for trunk
git-svn-id: https://develop.svn.wordpress.org/trunk@17431 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4d95849968
commit
7c37c82691
@ -132,6 +132,8 @@ class WP_Users_List_Table extends WP_List_Table {
|
|||||||
function extra_tablenav( $which ) {
|
function extra_tablenav( $which ) {
|
||||||
if ( 'top' != $which )
|
if ( 'top' != $which )
|
||||||
return;
|
return;
|
||||||
|
if ( ! current_user_can( 'promote_users' ) )
|
||||||
|
return;
|
||||||
?>
|
?>
|
||||||
<div class="alignleft actions">
|
<div class="alignleft actions">
|
||||||
<label class="screen-reader-text" for="new_role"><?php _e( 'Change role to…' ) ?></label>
|
<label class="screen-reader-text" for="new_role"><?php _e( 'Change role to…' ) ?></label>
|
||||||
|
@ -191,12 +191,18 @@ else
|
|||||||
if ( current_user_can('list_users') ) {
|
if ( current_user_can('list_users') ) {
|
||||||
$_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
|
$_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
|
||||||
$submenu['users.php'][5] = array(__('Users'), 'list_users', 'users.php');
|
$submenu['users.php'][5] = array(__('Users'), 'list_users', 'users.php');
|
||||||
|
if ( current_user_can('create_users') )
|
||||||
|
$submenu['users.php'][10] = array(_x('Add New', 'user'), 'create_users', 'user-new.php');
|
||||||
|
else
|
||||||
$submenu['users.php'][10] = array(_x('Add New', 'user'), 'promote_users', 'user-new.php');
|
$submenu['users.php'][10] = array(_x('Add New', 'user'), 'promote_users', 'user-new.php');
|
||||||
|
|
||||||
$submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php');
|
$submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php');
|
||||||
} else {
|
} else {
|
||||||
$_wp_real_parent_file['users.php'] = 'profile.php';
|
$_wp_real_parent_file['users.php'] = 'profile.php';
|
||||||
$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
|
$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
|
||||||
|
if ( current_user_can('create_users') )
|
||||||
|
$submenu['profile.php'][10] = array(__('Add New User'), 'create_users', 'user-new.php');
|
||||||
|
else
|
||||||
$submenu['profile.php'][10] = array(__('Add New User'), 'promote_users', 'user-new.php');
|
$submenu['profile.php'][10] = array(__('Add New User'), 'promote_users', 'user-new.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,12 @@
|
|||||||
/** WordPress Administration Bootstrap */
|
/** WordPress Administration Bootstrap */
|
||||||
require_once('./admin.php');
|
require_once('./admin.php');
|
||||||
|
|
||||||
if ( ! current_user_can('create_users') && ! current_user_can('promote_users') )
|
if ( is_multisite() ) {
|
||||||
wp_die(__('Cheatin’ uh?'));
|
if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) )
|
||||||
|
wp_die( __( 'Cheatin’ uh?' ) );
|
||||||
|
} elseif ( ! current_user_can( 'create_users' ) ) {
|
||||||
|
wp_die( __( 'Cheatin’ uh?' ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( is_multisite() ) {
|
if ( is_multisite() ) {
|
||||||
function admin_created_user_email( $text ) {
|
function admin_created_user_email( $text ) {
|
||||||
|
@ -48,6 +48,9 @@ switch ( $wp_list_table->current_action() ) {
|
|||||||
case 'promote':
|
case 'promote':
|
||||||
check_admin_referer('bulk-users');
|
check_admin_referer('bulk-users');
|
||||||
|
|
||||||
|
if ( ! current_user_can( 'promote_users' ) )
|
||||||
|
wp_die( __( 'You can’t edit that user.' ) );
|
||||||
|
|
||||||
if ( empty($_REQUEST['users']) ) {
|
if ( empty($_REQUEST['users']) ) {
|
||||||
wp_redirect($redirect);
|
wp_redirect($redirect);
|
||||||
exit();
|
exit();
|
||||||
@ -352,7 +355,7 @@ if ( ! empty($messages) ) {
|
|||||||
echo esc_html( $title );
|
echo esc_html( $title );
|
||||||
if ( current_user_can( 'create_users' ) ) { ?>
|
if ( current_user_can( 'create_users' ) ) { ?>
|
||||||
<a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
|
<a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
|
||||||
<?php } elseif ( current_user_can( 'promote_users' ) ) { ?>
|
<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
|
||||||
<a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
|
<a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
|
||||||
<?php }
|
<?php }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user