RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.78% (6.81%*) • Investment PI: 5.49% (6.32%*)

Disable Posting To WordPress REST API

This snippet prevents posting content to the WordPress REST API by validating that the method used is GET. It's another example of how the WordPress rest_authentication_errors filter might be used.

1
<?php 
2
/*
3
 Disable Posting To WordPress REST API
4
 http://www.beliefmedia.com/code/wp-snippets/disable-posting-wp-rest-api
5
*/
6
 
7
function beliefmedia_disable_posting_rest_api($access) {
8
  if ('GET' !== $_SERVER['REQUEST_METHOD']) {
9
    return new WP_Error( 'rest_cannot_access', 'Not authorized', array( 'status' => 405 ) );
10
  }
11
 return $access;
12
}
13
add_filter('rest_authentication_errors', beliefmedia_disable_posting_rest_api);

See also: Disable The WordPress Rest API.

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  E. Australia Standard Time [ UTC+10, Default ] [ CHECK TO CHANGE ]

  Want to have a chat?
 

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment