Jan 28, 2026 7:55 pm
Members can access the URL xxxxxxx/wp-admin. How can I fix this?
2 Replies
Jan 29, 2026 6:37 am
Hi,
Please follow this support topic:
https://wpforo.com/community/how-to-and-troubleshooting-2/how-to-completely-hide-backend-access/
The same question is discussed there.
Jan 29, 2026 10:30 am
I solved the problem. Add this to the functions file:
add_action('admin_init', 'restrict_wp_admin_only_admin');
function restrict_wp_admin_only_admin() {
if ( ! is_user_logged_in() ) {
wp_redirect(home_url());
exit;
}
if ( ! current_user_can('administrator') && ! wp_doing_ajax() ) {
wp_redirect(home_url());
exit;
}
}