79338769

Date: 2025-01-08 10:34:50
Score: 0.5
Natty:
Report link

Hook can be found here https://developer.wordpress.org/reference/hooks/rest_dispatch_request/

function wpse_authenticate_page_route( $dispatch_result, $request, $route, $handler ) {
    if ( strpos( $route, '/wp/v2/pages' ) !== false ) {
        return new \WP_Error(
            'rest_auth_required',
            'Authentication required',
            array( 'status' => 401 )
        );
    }
    return $dispatch_result;
}
add_filter( 'rest_dispatch_request', 'wpse_authenticate_page_route', 10, 4 );

You may want to check that blocking this route doesn't cause problems to Wordpress, they do say that blocking the API can break it. https://developer.wordpress.org/rest-api/frequently-asked-questions/#can-i-disable-the-rest-api

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Clement Duncan