From e7beccf78c57d1794df67362fc39c14d09e0639b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 3 Sep 2015 08:44:37 +0000 Subject: [PATCH] Provide more helpful feedback than just "Cheatin' uh?" for permission errors in `wp-admin/user-new.php`. props ericlewis, kraftbj, lukecarbis, mrmist. fixes #33678. see #14530. git-svn-id: https://develop.svn.wordpress.org/trunk@33884 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/user-new.php | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/wp-admin/user-new.php b/src/wp-admin/user-new.php index 28c46c63b4..e6028e8a54 100644 --- a/src/wp-admin/user-new.php +++ b/src/wp-admin/user-new.php @@ -10,10 +10,19 @@ require_once( dirname( __FILE__ ) . '/admin.php' ); if ( is_multisite() ) { - if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) - wp_die( __( 'Cheatin’ uh?' ), 403 ); + if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) { + wp_die( + '

' . __( 'Cheatin’ uh?' ) . '

' . + '

' . __( 'You do not have sufficient permissions to add users to this network.' ) . '

', + 403 + ); + } } elseif ( ! current_user_can( 'create_users' ) ) { - wp_die( __( 'Cheatin’ uh?' ), 403 ); + wp_die( + '

' . __( 'Cheatin’ uh?' ) . '

' . + '

' . __( 'You are not allowed to create users.' ) . '

', + 403 + ); } if ( is_multisite() ) { @@ -59,8 +68,13 @@ if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) { die(); } - if ( ! current_user_can('promote_user', $user_details->ID) ) - wp_die( __( 'Cheatin’ uh?' ), 403 ); + if ( ! current_user_can( 'promote_user', $user_details->ID ) ) { + wp_die( + '

' . __( 'Cheatin’ uh?' ) . '

' . + '

' . __( 'You do not have sufficient permissions to add users to this network.' ) . '

', + 403 + ); + } // Adding an existing user to this blog $new_user_email = $user_details->user_email; @@ -108,8 +122,13 @@ Please click the following link to confirm the invite: } elseif ( isset($_REQUEST['action']) && 'createuser' == $_REQUEST['action'] ) { check_admin_referer( 'create-user', '_wpnonce_create-user' ); - if ( ! current_user_can('create_users') ) - wp_die( __( 'Cheatin’ uh?' ), 403 ); + if ( ! current_user_can( 'create_users' ) ) { + wp_die( + '

' . __( 'Cheatin’ uh?' ) . '

' . + '

' . __( 'You are not allowed to create users.' ) . '

', + 403 + ); + } if ( ! is_multisite() ) { $user_id = edit_user();