How to hide Admin user from users list
Hi,
I don’t want other to know (see) site’s main Admin user, who even won’t take part in Anspress Q&A.
Is there anyway to exclude selected users to not to display in users list.
Apparently I Don’t want, to hide all Administrator’s. (e.g. in the screenshot attached I and admin two users are wordpress Administrator, I just don’t want admin user to display here)
Thanks
Regards
Hi
(IMPORTANT NOTICE:Don’t use default “admin” username! it’s so guessable. You can change it in your Cpanel or use “Username Changer” plugin & you can desable and remove it after each usernam-changing)
To (only) “hide” superadmin in users directory for non-admin members, please put this codes at the end of functions.php file in your theme.
add_action('pre_user_query','ap_pre_user_query'); function ap_pre_user_query($user_search) { $user = wp_get_current_user(); if ($user->ID!=1) { // Is not administrator, remove administrator (you can add any user-ID) global $wpdb; $user_search->query_where = str_replace('WHERE 1=1', "WHERE 1=1 AND {$wpdb->users}.ID<>1",$user_search->query_where); } }
This way only “hides” but if you need to hide your username completely (after hiding it by the codes) please use “Edit Author Slug” plugin. (you can remove your username-slug completely or change it).
GOOD LUCK!
You’re welcome! 🙂
I recommend you “Edit Author Slug” again, because your user_name is shown in your Auther-Url on your blog-posts (even if it’s hidden!).
Good luck!
Added this to road map, will be fixed in upcoming version.
Ok. Thanks.
@morteza, thanks for the tip. Changed the admin user name, your function also hid the the super-admin. 🙂