Using Contact Form 7 via the WP REST API

Having little access to the server on this external site, I used WordPress and WP REST API v2 to retrieve content that, of course, is managed on WordPress. Works great!

I was able to publish contact form 7 with the data of this external site on this WordPress site, and he sent an email, but the form did not pass the verification, and in the message he returns this error.

{
    "code": "rest_cannot_edit",
    "message": "Sorry, you are not allowed to edit this post.",
    "data": {
    "status": 401
}
} 

It publishes on the page https://www.flambang.com/wp-json/wp/v2/pages/1666?_=1498600326410#wpcf7-f11791-o1, and it’s strange that it even works - that is, send an email and Adds contact information to the database.

Has anyone used contact form 7 with data that is delivered via JSON via the WP REST API? Are there any other endpoints that I can use?

Thank,

Pavel

+5
source share
2 answers

Here is a link to the file that processes the rest of the APIs for the contact form 7. Maybe you can get help from there

0
source

You will need to use cookie authentication or another authentication method:

https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/

An example of its use can be found here:

https://github.com/ohze/wp-contact-form-7/blob/master/includes/js/scripts.js

0
source

Source: https://habr.com/ru/post/1680256/


All Articles