Title: Block by other logic
Author: WordPress VIP Documentation
Published: September 16, 2025

---

 1. [Security Controls](https://docs.wpvip.com/security-controls/)
 2. [Block unwanted origin requests with PHP](https://docs.wpvip.com/security-controls/block-origin-requests-with-php/)
 3. Block by other logic

#  Block by other logic

If the above methods are insufficient, a request can be blocked based on custom 
logic with the `VIP_Request_Block::block_and_log()` method. This method blocks a
request and logs a message to the `error_log`. The condition in which a given request
will be blocked must be defined using custom logic.

The following is an example of blocking a request to a specific URL:

vip-config/vip-config.php

    ```lang-php
    // Example VIP_Request_Block::block_and_log( string $value, string $criteria );
    if ( isset( $_SERVER['REQUEST_URI'] ) && '/disallowed-path' === $_SERVER['REQUEST_URI'] ) {
       if ( class_exists( 'VIP_Request_Block' ) ) {
         VIP_Request_Block::block_and_log( '/disallowed-path', 'REQUEST URI' );
       }
    }
    ```

In the example above, requests made to `/disallowed-path` will produce the following
message in the `error_log`:

    ```wp-block-preformatted
    VIP Request Block: request was blocked based on "REQUEST_URI" with value of "/disallowed-path"
    ```

Last updated: September 16, 2025