Standard technique for AJAX post endpoint: WP REST or WP API?

I need to create a post endpoint for a contact form that any user (not just logged in users) can use. The post is made via AJAX/REST.

Is the industry standard way to do this via a new WP REST endpoint? Ie,

add_action( ‘rest_api_init’, function () {
register_rest_route( ‘mytheme/v1’, ‘/contact’, array(
‘methods’ => ‘POST’,
‘callback’ => ‘my_awesome_func’,
) );

Or should we use the WP API and register a post action/filter/hook?

Read more here:: Standard technique for AJAX post endpoint: WP REST or WP API?

Leave a Reply

Your email address will not be published. Required fields are marked *