Support

Account

Home Forums Front-end Issues Blocking access to wp-admin while using a front-end form Reply To: Blocking access to wp-admin while using a front-end form

  • you’re right – the is_admin() is not needed, but I swapped all the is/isnot (!) to be correct from your code, and it didn’t work for me.

    this is working absolutely perfectly for me.

    add_action( 'admin_init', 'redirect_admin' );
    function redirect_admin() {
        if ( ! current_user_can( 'administrator' ) && ! (defined( 'DOING_AJAX' ) && DOING_AJAX ) ){
            wp_redirect( "http://www.cultshare.co.uk/404.php");
            exit;
        }
    }