Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active May 24, 2021 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/37f45031be10f30e27dbba63b46bcec6 to your computer and use it in GitHub Desktop.
Save cliffordp/37f45031be10f30e27dbba63b46bcec6 to your computer and use it in GitHub Desktop.
Disable The Events Calendar's REST API functionality.
<?php
/**
* Disable The Events Calendar's and Event Tickets' REST API functionality.
*
* The Events Calendar: Will disallow other sites running Event Aggregator from importing events from the site with the
* REST API disabled.
* Event Tickets: Will disallow using Modern Tribe's QR Code Scanner app.
*
* @link https://gist.github.com/cliffordp/37f45031be10f30e27dbba63b46bcec6
*/
add_filter( 'tribe_events_rest_api_enabled', '__return_false' );
add_filter( 'tribe_tickets_rest_api_enabled', '__return_false' );
@rkaiser0324
Copy link

Works great; just note that it needs to be in a MU plugin, rather than the theme, so that it will get loaded early enough.

@IanDelMar
Copy link

This may not be sufficient to disable the REST API functionality according to https://theeventscalendar.com/support/forums/topic/how-disable-wp-json-of-tribe-events/:

// Advertise to the world that the REST API is disabled.
add_filter( 'tribe_events_rest_api_enabled', '__return_false' );

// Actually disable REST API functionality.
add_action( 'init', function () {
  remove_action(
    'rest_api_init',
    array( tribe( 'tec.rest-v1.main' ), 'register_endpoints' )
 );
}, 5 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment