Skip to content

Instantly share code, notes, and snippets.

@anka
Created April 7, 2023 18:11
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 anka/3f4c813f9397ddba208d1be40bb8b966 to your computer and use it in GitHub Desktop.
Save anka/3f4c813f9397ddba208d1be40bb8b966 to your computer and use it in GitHub Desktop.
Wordpress plugin code to register a custom route
add_action('rest_api_init', 'register_custom_route');
function register_custom_route() {
register_rest_route('custom-api-route/v1', '/submit', array(
'methods' => 'POST',
'callback' => 'process_data_submission',
'permission_callback' => '__return_true',
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment