Edit File by line
/home/barbar84/www/wp-admin
File: users.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* User administration panel
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
* @since 1.0.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/** WordPress Administration Bootstrap */
[9] Fix | Delete
require_once __DIR__ . '/admin.php';
[10] Fix | Delete
[11] Fix | Delete
if ( ! current_user_can( 'list_users' ) ) {
[12] Fix | Delete
wp_die(
[13] Fix | Delete
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
[14] Fix | Delete
'<p>' . __( 'Sorry, you are not allowed to list users.' ) . '</p>',
[15] Fix | Delete
403
[16] Fix | Delete
);
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
$wp_list_table = _get_list_table( 'WP_Users_List_Table' );
[20] Fix | Delete
$pagenum = $wp_list_table->get_pagenum();
[21] Fix | Delete
$title = __( 'Users' );
[22] Fix | Delete
$parent_file = 'users.php';
[23] Fix | Delete
[24] Fix | Delete
add_screen_option( 'per_page' );
[25] Fix | Delete
[26] Fix | Delete
// Contextual help - choose Help on the top right of admin panel to preview this.
[27] Fix | Delete
get_current_screen()->add_help_tab(
[28] Fix | Delete
array(
[29] Fix | Delete
'id' => 'overview',
[30] Fix | Delete
'title' => __( 'Overview' ),
[31] Fix | Delete
'content' => '<p>' . __( 'This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.' ) . '</p>' .
[32] Fix | Delete
'<p>' . __( 'To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.' ) . '</p>',
[33] Fix | Delete
)
[34] Fix | Delete
);
[35] Fix | Delete
[36] Fix | Delete
get_current_screen()->add_help_tab(
[37] Fix | Delete
array(
[38] Fix | Delete
'id' => 'screen-content',
[39] Fix | Delete
'title' => __( 'Screen Content' ),
[40] Fix | Delete
'content' => '<p>' . __( 'You can customize the display of this screen in a number of ways:' ) . '</p>' .
[41] Fix | Delete
'<ul>' .
[42] Fix | Delete
'<li>' . __( 'You can hide/display columns based on your needs and decide how many users to list per screen using the Screen Options tab.' ) . '</li>' .
[43] Fix | Delete
'<li>' . __( 'You can filter the list of users by User Role using the text links above the users list to show All, Administrator, Editor, Author, Contributor, or Subscriber. The default view is to show all users. Unused User Roles are not listed.' ) . '</li>' .
[44] Fix | Delete
'<li>' . __( 'You can view all posts made by a user by clicking on the number under the Posts column.' ) . '</li>' .
[45] Fix | Delete
'</ul>',
[46] Fix | Delete
)
[47] Fix | Delete
);
[48] Fix | Delete
[49] Fix | Delete
$help = '<p>' . __( 'Hovering over a row in the users list will display action links that allow you to manage users. You can perform the following actions:' ) . '</p>' .
[50] Fix | Delete
'<ul>' .
[51] Fix | Delete
'<li>' . __( '<strong>Edit</strong> takes you to the editable profile screen for that user. You can also reach that screen by clicking on the username.' ) . '</li>';
[52] Fix | Delete
[53] Fix | Delete
if ( is_multisite() ) {
[54] Fix | Delete
$help .= '<li>' . __( '<strong>Remove</strong> allows you to remove a user from your site. It does not delete their content. You can also remove multiple users at once by using bulk actions.' ) . '</li>';
[55] Fix | Delete
} else {
[56] Fix | Delete
$help .= '<li>' . __( '<strong>Delete</strong> brings you to the Delete Users screen for confirmation, where you can permanently remove a user from your site and delete their content. You can also delete multiple users at once by using bulk actions.' ) . '</li>';
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
$help .= '</ul>';
[60] Fix | Delete
[61] Fix | Delete
get_current_screen()->add_help_tab(
[62] Fix | Delete
array(
[63] Fix | Delete
'id' => 'action-links',
[64] Fix | Delete
'title' => __( 'Available Actions' ),
[65] Fix | Delete
'content' => $help,
[66] Fix | Delete
)
[67] Fix | Delete
);
[68] Fix | Delete
unset( $help );
[69] Fix | Delete
[70] Fix | Delete
get_current_screen()->set_help_sidebar(
[71] Fix | Delete
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
[72] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/article/users-screen/">Documentation on Managing Users</a>' ) . '</p>' .
[73] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/article/roles-and-capabilities/">Descriptions of Roles and Capabilities</a>' ) . '</p>' .
[74] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
[75] Fix | Delete
);
[76] Fix | Delete
[77] Fix | Delete
get_current_screen()->set_screen_reader_content(
[78] Fix | Delete
array(
[79] Fix | Delete
'heading_views' => __( 'Filter users list' ),
[80] Fix | Delete
'heading_pagination' => __( 'Users list navigation' ),
[81] Fix | Delete
'heading_list' => __( 'Users list' ),
[82] Fix | Delete
)
[83] Fix | Delete
);
[84] Fix | Delete
[85] Fix | Delete
if ( empty( $_REQUEST ) ) {
[86] Fix | Delete
$referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
[87] Fix | Delete
} elseif ( isset( $_REQUEST['wp_http_referer'] ) ) {
[88] Fix | Delete
$redirect = remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), wp_unslash( $_REQUEST['wp_http_referer'] ) );
[89] Fix | Delete
$referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( $redirect ) . '" />';
[90] Fix | Delete
} else {
[91] Fix | Delete
$redirect = 'users.php';
[92] Fix | Delete
$referer = '';
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
$update = '';
[96] Fix | Delete
[97] Fix | Delete
switch ( $wp_list_table->current_action() ) {
[98] Fix | Delete
[99] Fix | Delete
/* Bulk Dropdown menu Role changes */
[100] Fix | Delete
case 'promote':
[101] Fix | Delete
check_admin_referer( 'bulk-users' );
[102] Fix | Delete
[103] Fix | Delete
if ( ! current_user_can( 'promote_users' ) ) {
[104] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 );
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
if ( empty( $_REQUEST['users'] ) ) {
[108] Fix | Delete
wp_redirect( $redirect );
[109] Fix | Delete
exit;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
$editable_roles = get_editable_roles();
[113] Fix | Delete
$role = $_REQUEST['new_role'];
[114] Fix | Delete
[115] Fix | Delete
// Mocking the `none` role so we are able to save it to the database
[116] Fix | Delete
$editable_roles['none'] = array(
[117] Fix | Delete
'name' => __( '&mdash; No role for this site &mdash;' ),
[118] Fix | Delete
);
[119] Fix | Delete
[120] Fix | Delete
if ( ! $role || empty( $editable_roles[ $role ] ) ) {
[121] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
if ( 'none' === $role ) {
[125] Fix | Delete
$role = '';
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
$userids = $_REQUEST['users'];
[129] Fix | Delete
$update = 'promote';
[130] Fix | Delete
foreach ( $userids as $id ) {
[131] Fix | Delete
$id = (int) $id;
[132] Fix | Delete
[133] Fix | Delete
if ( ! current_user_can( 'promote_user', $id ) ) {
[134] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 );
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
// The new role of the current user must also have the promote_users cap or be a multisite super admin.
[138] Fix | Delete
if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap( 'promote_users' )
[139] Fix | Delete
&& ! ( is_multisite() && current_user_can( 'manage_network_users' ) ) ) {
[140] Fix | Delete
$update = 'err_admin_role';
[141] Fix | Delete
continue;
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
// If the user doesn't already belong to the blog, bail.
[145] Fix | Delete
if ( is_multisite() && ! is_user_member_of_blog( $id ) ) {
[146] Fix | Delete
wp_die(
[147] Fix | Delete
'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
[148] Fix | Delete
'<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>',
[149] Fix | Delete
403
[150] Fix | Delete
);
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
$user = get_userdata( $id );
[154] Fix | Delete
$user->set_role( $role );
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
wp_redirect( add_query_arg( 'update', $update, $redirect ) );
[158] Fix | Delete
exit;
[159] Fix | Delete
[160] Fix | Delete
case 'dodelete':
[161] Fix | Delete
if ( is_multisite() ) {
[162] Fix | Delete
wp_die( __( 'User deletion is not allowed from this screen.' ), 400 );
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
check_admin_referer( 'delete-users' );
[166] Fix | Delete
[167] Fix | Delete
if ( empty( $_REQUEST['users'] ) ) {
[168] Fix | Delete
wp_redirect( $redirect );
[169] Fix | Delete
exit;
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
[173] Fix | Delete
[174] Fix | Delete
if ( empty( $_REQUEST['delete_option'] ) ) {
[175] Fix | Delete
$url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $userids ) . '&error=true' );
[176] Fix | Delete
$url = str_replace( '&amp;', '&', wp_nonce_url( $url, 'bulk-users' ) );
[177] Fix | Delete
wp_redirect( $url );
[178] Fix | Delete
exit;
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
if ( ! current_user_can( 'delete_users' ) ) {
[182] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to delete users.' ), 403 );
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
$update = 'del';
[186] Fix | Delete
$delete_count = 0;
[187] Fix | Delete
[188] Fix | Delete
foreach ( $userids as $id ) {
[189] Fix | Delete
if ( ! current_user_can( 'delete_user', $id ) ) {
[190] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to delete that user.' ), 403 );
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
if ( $id == $current_user->ID ) {
[194] Fix | Delete
$update = 'err_admin_del';
[195] Fix | Delete
continue;
[196] Fix | Delete
}
[197] Fix | Delete
switch ( $_REQUEST['delete_option'] ) {
[198] Fix | Delete
case 'delete':
[199] Fix | Delete
wp_delete_user( $id );
[200] Fix | Delete
break;
[201] Fix | Delete
case 'reassign':
[202] Fix | Delete
wp_delete_user( $id, $_REQUEST['reassign_user'] );
[203] Fix | Delete
break;
[204] Fix | Delete
}
[205] Fix | Delete
++$delete_count;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
$redirect = add_query_arg(
[209] Fix | Delete
array(
[210] Fix | Delete
'delete_count' => $delete_count,
[211] Fix | Delete
'update' => $update,
[212] Fix | Delete
),
[213] Fix | Delete
$redirect
[214] Fix | Delete
);
[215] Fix | Delete
wp_redirect( $redirect );
[216] Fix | Delete
exit;
[217] Fix | Delete
[218] Fix | Delete
case 'resetpassword':
[219] Fix | Delete
check_admin_referer( 'bulk-users' );
[220] Fix | Delete
if ( ! current_user_can( 'edit_users' ) ) {
[221] Fix | Delete
$errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to edit users.' ) );
[222] Fix | Delete
}
[223] Fix | Delete
if ( empty( $_REQUEST['users'] ) ) {
[224] Fix | Delete
wp_redirect( $redirect );
[225] Fix | Delete
exit();
[226] Fix | Delete
}
[227] Fix | Delete
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
[228] Fix | Delete
[229] Fix | Delete
$reset_count = 0;
[230] Fix | Delete
[231] Fix | Delete
foreach ( $userids as $id ) {
[232] Fix | Delete
if ( ! current_user_can( 'edit_user', $id ) ) {
[233] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
if ( $id === $current_user->ID ) {
[237] Fix | Delete
$update = 'err_admin_reset';
[238] Fix | Delete
continue;
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
// Send the password reset link.
[242] Fix | Delete
$user = get_userdata( $id );
[243] Fix | Delete
if ( retrieve_password( $user->user_login ) ) {
[244] Fix | Delete
++$reset_count;
[245] Fix | Delete
}
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
$redirect = add_query_arg(
[249] Fix | Delete
array(
[250] Fix | Delete
'reset_count' => $reset_count,
[251] Fix | Delete
'update' => 'resetpassword',
[252] Fix | Delete
),
[253] Fix | Delete
$redirect
[254] Fix | Delete
);
[255] Fix | Delete
wp_redirect( $redirect );
[256] Fix | Delete
exit;
[257] Fix | Delete
[258] Fix | Delete
case 'delete':
[259] Fix | Delete
if ( is_multisite() ) {
[260] Fix | Delete
wp_die( __( 'User deletion is not allowed from this screen.' ), 400 );
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
check_admin_referer( 'bulk-users' );
[264] Fix | Delete
[265] Fix | Delete
if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) {
[266] Fix | Delete
wp_redirect( $redirect );
[267] Fix | Delete
exit;
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
if ( ! current_user_can( 'delete_users' ) ) {
[271] Fix | Delete
$errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to delete users.' ) );
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
if ( empty( $_REQUEST['users'] ) ) {
[275] Fix | Delete
$userids = array( (int) $_REQUEST['user'] );
[276] Fix | Delete
} else {
[277] Fix | Delete
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
$all_userids = $userids;
[281] Fix | Delete
[282] Fix | Delete
if ( in_array( $current_user->ID, $userids, true ) ) {
[283] Fix | Delete
$userids = array_diff( $userids, array( $current_user->ID ) );
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
/**
[287] Fix | Delete
* Filters whether the users being deleted have additional content
[288] Fix | Delete
* associated with them outside of the `post_author` and `link_owner` relationships.
[289] Fix | Delete
*
[290] Fix | Delete
* @since 5.2.0
[291] Fix | Delete
*
[292] Fix | Delete
* @param bool $users_have_additional_content Whether the users have additional content. Default false.
[293] Fix | Delete
* @param int[] $userids Array of IDs for users being deleted.
[294] Fix | Delete
*/
[295] Fix | Delete
$users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids );
[296] Fix | Delete
[297] Fix | Delete
if ( $userids && ! $users_have_content ) {
[298] Fix | Delete
if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
[299] Fix | Delete
$users_have_content = true;
[300] Fix | Delete
} elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
[301] Fix | Delete
$users_have_content = true;
[302] Fix | Delete
}
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
if ( $users_have_content ) {
[306] Fix | Delete
add_action( 'admin_head', 'delete_users_add_js' );
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[310] Fix | Delete
?>
[311] Fix | Delete
<form method="post" name="updateusers" id="updateusers">
[312] Fix | Delete
<?php wp_nonce_field( 'delete-users' ); ?>
[313] Fix | Delete
<?php echo $referer; ?>
[314] Fix | Delete
[315] Fix | Delete
<div class="wrap">
[316] Fix | Delete
<h1><?php _e( 'Delete Users' ); ?></h1>
[317] Fix | Delete
<?php if ( isset( $_REQUEST['error'] ) ) : ?>
[318] Fix | Delete
<div class="error">
[319] Fix | Delete
<p><strong><?php _e( 'Error:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p>
[320] Fix | Delete
</div>
[321] Fix | Delete
<?php endif; ?>
[322] Fix | Delete
[323] Fix | Delete
<?php if ( 1 === count( $all_userids ) ) : ?>
[324] Fix | Delete
<p><?php _e( 'You have specified this user for deletion:' ); ?></p>
[325] Fix | Delete
<?php else : ?>
[326] Fix | Delete
<p><?php _e( 'You have specified these users for deletion:' ); ?></p>
[327] Fix | Delete
<?php endif; ?>
[328] Fix | Delete
[329] Fix | Delete
<ul>
[330] Fix | Delete
<?php
[331] Fix | Delete
$go_delete = 0;
[332] Fix | Delete
foreach ( $all_userids as $id ) {
[333] Fix | Delete
$user = get_userdata( $id );
[334] Fix | Delete
if ( $id == $current_user->ID ) {
[335] Fix | Delete
/* translators: 1: User ID, 2: User login. */
[336] Fix | Delete
echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>' ), $id, $user->user_login ) . "</li>\n";
[337] Fix | Delete
} else {
[338] Fix | Delete
/* translators: 1: User ID, 2: User login. */
[339] Fix | Delete
echo '<li><input type="hidden" name="users[]" value="' . esc_attr( $id ) . '" />' . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n";
[340] Fix | Delete
$go_delete++;
[341] Fix | Delete
}
[342] Fix | Delete
}
[343] Fix | Delete
?>
[344] Fix | Delete
</ul>
[345] Fix | Delete
<?php
[346] Fix | Delete
if ( $go_delete ) :
[347] Fix | Delete
[348] Fix | Delete
if ( ! $users_have_content ) :
[349] Fix | Delete
?>
[350] Fix | Delete
<input type="hidden" name="delete_option" value="delete" />
[351] Fix | Delete
<?php else : ?>
[352] Fix | Delete
<?php if ( 1 == $go_delete ) : ?>
[353] Fix | Delete
<fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p>
[354] Fix | Delete
<?php else : ?>
[355] Fix | Delete
<fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p>
[356] Fix | Delete
<?php endif; ?>
[357] Fix | Delete
<ul style="list-style:none;">
[358] Fix | Delete
<li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" />
[359] Fix | Delete
<?php _e( 'Delete all content.' ); ?></label></li>
[360] Fix | Delete
<li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
[361] Fix | Delete
<?php
[362] Fix | Delete
echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> ';
[363] Fix | Delete
wp_dropdown_users(
[364] Fix | Delete
array(
[365] Fix | Delete
'name' => 'reassign_user',
[366] Fix | Delete
'exclude' => $userids,
[367] Fix | Delete
'show' => 'display_name_with_login',
[368] Fix | Delete
)
[369] Fix | Delete
);
[370] Fix | Delete
?>
[371] Fix | Delete
</li>
[372] Fix | Delete
</ul></fieldset>
[373] Fix | Delete
<?php
[374] Fix | Delete
endif;
[375] Fix | Delete
/**
[376] Fix | Delete
* Fires at the end of the delete users form prior to the confirm button.
[377] Fix | Delete
*
[378] Fix | Delete
* @since 4.0.0
[379] Fix | Delete
* @since 4.5.0 The `$userids` parameter was added.
[380] Fix | Delete
*
[381] Fix | Delete
* @param WP_User $current_user WP_User object for the current user.
[382] Fix | Delete
* @param int[] $userids Array of IDs for users being deleted.
[383] Fix | Delete
*/
[384] Fix | Delete
do_action( 'delete_user_form', $current_user, $userids );
[385] Fix | Delete
?>
[386] Fix | Delete
<input type="hidden" name="action" value="dodelete" />
[387] Fix | Delete
<?php submit_button( __( 'Confirm Deletion' ), 'primary' ); ?>
[388] Fix | Delete
<?php else : ?>
[389] Fix | Delete
<p><?php _e( 'There are no valid users selected for deletion.' ); ?></p>
[390] Fix | Delete
<?php endif; ?>
[391] Fix | Delete
</div>
[392] Fix | Delete
</form>
[393] Fix | Delete
<?php
[394] Fix | Delete
[395] Fix | Delete
break;
[396] Fix | Delete
[397] Fix | Delete
case 'doremove':
[398] Fix | Delete
check_admin_referer( 'remove-users' );
[399] Fix | Delete
[400] Fix | Delete
if ( ! is_multisite() ) {
[401] Fix | Delete
wp_die( __( 'You can&#8217;t remove users.' ), 400 );
[402] Fix | Delete
}
[403] Fix | Delete
[404] Fix | Delete
if ( empty( $_REQUEST['users'] ) ) {
[405] Fix | Delete
wp_redirect( $redirect );
[406] Fix | Delete
exit;
[407] Fix | Delete
}
[408] Fix | Delete
[409] Fix | Delete
if ( ! current_user_can( 'remove_users' ) ) {
[410] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to remove users.' ), 403 );
[411] Fix | Delete
}
[412] Fix | Delete
[413] Fix | Delete
$userids = $_REQUEST['users'];
[414] Fix | Delete
[415] Fix | Delete
$update = 'remove';
[416] Fix | Delete
foreach ( $userids as $id ) {
[417] Fix | Delete
$id = (int) $id;
[418] Fix | Delete
if ( ! current_user_can( 'remove_user', $id ) ) {
[419] Fix | Delete
$update = 'err_admin_remove';
[420] Fix | Delete
continue;
[421] Fix | Delete
}
[422] Fix | Delete
remove_user_from_blog( $id, $blog_id );
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
$redirect = add_query_arg( array( 'update' => $update ), $redirect );
[426] Fix | Delete
wp_redirect( $redirect );
[427] Fix | Delete
exit;
[428] Fix | Delete
[429] Fix | Delete
case 'remove':
[430] Fix | Delete
check_admin_referer( 'bulk-users' );
[431] Fix | Delete
[432] Fix | Delete
if ( ! is_multisite() ) {
[433] Fix | Delete
wp_die( __( 'You can&#8217;t remove users.' ), 400 );
[434] Fix | Delete
}
[435] Fix | Delete
[436] Fix | Delete
if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) {
[437] Fix | Delete
wp_redirect( $redirect );
[438] Fix | Delete
exit;
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
if ( ! current_user_can( 'remove_users' ) ) {
[442] Fix | Delete
$error = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to remove users.' ) );
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
if ( empty( $_REQUEST['users'] ) ) {
[446] Fix | Delete
$userids = array( (int) $_REQUEST['user'] );
[447] Fix | Delete
} else {
[448] Fix | Delete
$userids = $_REQUEST['users'];
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[452] Fix | Delete
?>
[453] Fix | Delete
<form method="post" name="updateusers" id="updateusers">
[454] Fix | Delete
<?php wp_nonce_field( 'remove-users' ); ?>
[455] Fix | Delete
<?php echo $referer; ?>
[456] Fix | Delete
[457] Fix | Delete
<div class="wrap">
[458] Fix | Delete
<h1><?php _e( 'Remove Users from Site' ); ?></h1>
[459] Fix | Delete
[460] Fix | Delete
<?php if ( 1 === count( $userids ) ) : ?>
[461] Fix | Delete
<p><?php _e( 'You have specified this user for removal:' ); ?></p>
[462] Fix | Delete
<?php else : ?>
[463] Fix | Delete
<p><?php _e( 'You have specified these users for removal:' ); ?></p>
[464] Fix | Delete
<?php endif; ?>
[465] Fix | Delete
[466] Fix | Delete
<ul>
[467] Fix | Delete
<?php
[468] Fix | Delete
$go_remove = false;
[469] Fix | Delete
foreach ( $userids as $id ) {
[470] Fix | Delete
$id = (int) $id;
[471] Fix | Delete
$user = get_userdata( $id );
[472] Fix | Delete
if ( ! current_user_can( 'remove_user', $id ) ) {
[473] Fix | Delete
/* translators: 1: User ID, 2: User login. */
[474] Fix | Delete
echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>Sorry, you are not allowed to remove this user.</strong>' ), $id, $user->user_login ) . "</li>\n";
[475] Fix | Delete
} else {
[476] Fix | Delete
/* translators: 1: User ID, 2: User login. */
[477] Fix | Delete
echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n";
[478] Fix | Delete
$go_remove = true;
[479] Fix | Delete
}
[480] Fix | Delete
}
[481] Fix | Delete
?>
[482] Fix | Delete
</ul>
[483] Fix | Delete
<?php if ( $go_remove ) : ?>
[484] Fix | Delete
<input type="hidden" name="action" value="doremove" />
[485] Fix | Delete
<?php submit_button( __( 'Confirm Removal' ), 'primary' ); ?>
[486] Fix | Delete
<?php else : ?>
[487] Fix | Delete
<p><?php _e( 'There are no valid users selected for removal.' ); ?></p>
[488] Fix | Delete
<?php endif; ?>
[489] Fix | Delete
</div>
[490] Fix | Delete
</form>
[491] Fix | Delete
<?php
[492] Fix | Delete
[493] Fix | Delete
break;
[494] Fix | Delete
[495] Fix | Delete
default:
[496] Fix | Delete
if ( ! empty( $_GET['_wp_http_referer'] ) ) {
[497] Fix | Delete
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
[498] Fix | Delete
exit;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function