Search code examples
wordpressrestcontact-form-7wordpress-rest-apininja-forms

How can I access my wordpress form data through REST API


The word press website I am creating involves quite a lot of form filling. I've tried using a ninja forms and contact-form-7 and I want to fetch my form submissions through REST API. But ninja forms just doesn't have much documentation for this and contact-form-7 gives me an error:

http://localhost/wordpress/wp-json/contact-form-7/v1/contact-forms

ERROR

{
    "code": "wpcf7_forbidden",
    "message": "You are not allowed to access contact forms.",
    "data": {
        "status": 403
    }
}

How should I go about this? Is there any way to use REST API for form data on wordpress? If anyone could point me in the right direction I would be so thankful


Solution

  • Contact Form 7 (<=5.1.4) does not store any submission data in the database. I've tested Contact Form CFDB7 (<=1.2.4.8), Contact Form Entries (<=1.0.8), Flamingo (<=2.1) add-ons for Contact Form 7 and none of those provide Rest API endpoints to collect form submission data ether.

    Ninja Forms (<=3.4.21) does not expose any Rest API endpoints.

    You have couple options at this point:

    • Submit a request to CF7 or/and Ninja Forms developers requesting a feature.
    • Look for existing plugin / extension that does this (free or premium).
    • Implement Rest API yourself. It's not very complicated and can be implemented as separate plugin. You will not have to modify CF7/Ninja Forms plugins to make it work. Here is WordPress documentation: https://developer.wordpress.org/rest-api/extending-the-rest-api/