There are examples on WordPress Stackexchange that recommend code equivalent to:
/** Disguise Administrator From Person Record **/
operate isa_pre_user_query( $user_search ) {
if ( !current_user_can( 'administrator' ) ) { // Is Not Administrator - Take away Administrator
international $wpdb;
$user_search->query_where = str_replace(
'WHERE 1=1',
"WHERE 1=1 AND {$wpdb->customers}.ID IN (
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
WHERE {$wpdb->usermeta}.meta_key = '{$wpdb->prefix}capabilities'
AND {$wpdb->usermeta}.meta_value NOT LIKE '%administrator%' )",
$user_search->query_where
);
}
}
add_action( 'pre_user_query', 'isa_pre_user_query' );
There’s additionally a tutorial from Misha Rudrastyh
with an identical method.
Is there a approach to obtain an identical consequence with a local WordPress operate?