• Hi,

    I wonder if anyone knows a plugin that will automatically block all visitors if they are trying to search for admin page? Basically if you type (website.com/admin) you will get blocked straight away and you won’t be able to access the website anymore you will have message displayed saying that if you want to access the wesbite you have to give us a call.

    Many thanks,

Viewing 1 replies (of 1 total)
  • Hi @uvireuvire

    There’s a way to redirect users back to the homepage if they try to access your admin dashboard. You just need to add the following piece of code into your functions.php file.

    add_action( ‘init’, ‘blockusers_init’ );

    function blockusers_init() {
    if ( is_admin() && ! current_user_can( ‘administrator’ ) &&
    ! ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) ) {
    wp_redirect( home_url() );
    exit;
    }
    }

    Let me know if that works

Viewing 1 replies (of 1 total)
  • The topic ‘Block visit if trying to access admin’ is closed to new replies.