Support » Plugin: Honeypot for Contact Form 7 » ajax honeypot

  • Resolved jacksonkr_

    (@jacksonkr_)


    I’m using wp-json/v2 and reactjs to display my website

    currently I’m displaying all the html of the contact form (using dangerouslySetInnerHTML) and on “send” I’m creating a post and adding each element into the post body.

    Post body stringified: “{“_wpcf7″:”868″,”_wpcf7_version”:”5.1.7″,”_wpcf7_locale”:”en_US”,”_wpcf7_unit_tag”:”wpcf7-f868-o1″,”_wpcf7_container_post”:”0″,”your-email”:”user@mail.net”,””:”Send”,”honeypot-156″:””,”your-message”:”this is a test email”}”

    I’m receiving a 401 (unauthorized)

    What am I missing ?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Ryan

    (@nocean)

    I’m sorry, I’m really not sure, as I’ve no experience working with wp-json/reactjs. I’ll leave the issue open for a while, in case any other users have experience with this.

    Thread Starter jacksonkr_

    (@jacksonkr_)

    Thanks for following up, I’ve since solved this issue. What I did:

    https://conditional-fields-cf7.bdwm.be/ajax-example/

    After reviewing that post I found that I needed to dynamically load one of the javascript files at runtime. I used the following code (reactjs)

        componentDidMount() {
            // add honeypot scripts (requires jquery) @jkr
            try {
                const div = this.refDiv.current;
                const script = document.createElement("script");
                script.async = true;
                script.src = <code>${process.env.REACT_APP_WP_URL}/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=5.1.7</code>;
                div.appendChild(script);
            } catch (e) {
                console.warn(e);
            }
        }

    There may have been an additional script I added somewhere but it’s been so long I can’t remember. Regardless this should help out anyone who’s looking to do the same as me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.