Last active
August 29, 2015 14:05
-
-
Save norcross/e54978fe2a3f428b7217 to your computer and use it in GitHub Desktop.
modify user dropdown in delete page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rkv_limit_users_delete( $query ) { | |
// first fetch the screen | |
$screen = get_current_screen(); | |
// bail if we aren't on our user screen | |
if ( ! is_object( $screen ) || empty( $screen->base ) || ! empty( $screen->base ) && $screen->base != 'users' ) { | |
return $query; | |
} | |
// check that we are on our delete call | |
if ( ! isset( $_REQUEST['action'] ) || ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] != 'delete' ) { | |
return $query; | |
} | |
// get our current user | |
$user_id = get_current_user_id(); | |
// call the global DB class | |
global $wpdb; | |
// modify our where clause to include the user ID | |
$query->query_where .= $wpdb->prepare( " AND $wpdb->users.ID = %d ", absint( $user_id ) ); | |
// send it back | |
return $query; | |
} | |
add_filter( 'pre_user_query', 'rkv_limit_users_delete' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment