Notifications
Clear all

[Solved] Members can access the wp-admin page.

3 Posts
2 Users
0 Reactions
157 Views
Posts: 12
Topic starter
(@plaka37)
Eminent Member
Joined: 4 weeks ago

Members can access the URL xxxxxxx/wp-admin. How can I fix this?


2 Replies
Sofy
Posts: 5733
 Sofy
Admin
(@sofy)
Support Team
Joined: 8 years ago

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.


Posts: 12
Topic starter
(@plaka37)
Eminent Member
Joined: 4 weeks ago

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;
    }
}