<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ronny Freites on Medium]]></title>
        <description><![CDATA[Stories by Ronny Freites on Medium]]></description>
        <link>https://medium.com/@ronnyiscoding?source=rss-2e29f65233b1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hThsoH_axH_SrXV0xuT7LA.jpeg</url>
            <title>Stories by Ronny Freites on Medium</title>
            <link>https://medium.com/@ronnyiscoding?source=rss-2e29f65233b1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 03:48:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ronnyiscoding/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Connecting Contact Form 7 WordPress plugin with Gatsbyjs]]></title>
            <link>https://medium.com/@ronnyiscoding/connecting-contact-form-7-wordpress-plugin-with-gatsbyjs-1c68f472b0fd?source=rss-2e29f65233b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c68f472b0fd</guid>
            <category><![CDATA[axios]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[gatsbyjs]]></category>
            <category><![CDATA[formik]]></category>
            <category><![CDATA[contact-form-7]]></category>
            <dc:creator><![CDATA[Ronny Freites]]></dc:creator>
            <pubDate>Sun, 08 Mar 2020 21:41:37 GMT</pubDate>
            <atom:updated>2020-03-08T22:50:12.710Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lX6ex97zNuBC7SaKKvJ6_A.png" /></figure><p>I really like to build websites on <a href="https://wordpress.org/">WordPress</a>, IMO I think is one of the most powerful ways to build a website, more than 55,840 <a href="https://wordpress.org/plugins/">plugins</a> available to extend or add new functionalities to your website on WordPress, so it is a great cms solution even as headless cms is very useful.</p><p>What about Gatsbyjs? according to <a href="https://www.gatsbyjs.org/">Gatsbyjs</a> website:</p><blockquote>“Gatsby is a free and open source framework based on React that helps developers build blazing fast <strong>websites</strong> and <strong>apps”</strong></blockquote><p>So we can found on Gatsbyjs a great solution to create a very faster website, and something really interesting with Gatsby is that it actually uses <a href="https://reactjs.org/">Reactjs</a>, so this allows us to use all Reactjs features like hooks, context API, etc.</p><p>Let’s start working on our form on Gatsbyjs connected to WordPress using <a href="https://wordpress.org/plugins/contact-form-7/">Contat Form 7</a> plugin.</p><p>We will need to have running a WordPress website instance, which could be locally or in a hosting provider.</p><h3>We will need to be had installed and activated these following WordPress plugins:</h3><p><a href="https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/">JWT Authentication for WP-API</a>: this will helped us to authenticate a user that will be used to send the form submission to our WordPress instance.</p><p><a href="https://wordpress.org/plugins/wp-cors/">WP-CORS</a>: This plugin will allow ajax request, from whatever you are connecting your Gatsbyjs site to our WordPress instance.</p><p><a href="https://wordpress.org/plugins/contact-form-7/">Contact Form 7</a>: this will be the plugin where we are going to create our form to be exposed in wp rest API.</p><p><a href="https://wordpress.org/plugins/members/">User Role Editor by Members — Best User, Role and Capability Management Plugin for WordPress</a>: this will be help full to add user capabilities to send form submissions through wp rest API.</p><h3>Let&#39;s start setting up our plugins</h3><p><a href="https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/">JWT Authentication for WP-API</a></p><h4><strong>Configure the secret key</strong></h4><p>The JWT needs a <strong>secret key</strong> to sign the token this <strong>secret key</strong> must be unique and never revealed.</p><p>To add the <strong>secret key</strong> edit your wp-config.php file and add a new constant called <strong>JWT_AUTH_SECRET_KEY</strong></p><pre>define(&#39;JWT_AUTH_SECRET_KEY&#39;, &#39;your-top-secret-key&#39;);</pre><p>You can use a string from here <a href="https://api.wordpress.org/secret-key/1.1/salt/">https://api.wordpress.org/secret-key/1.1/salt/</a></p><p><strong>Configure CORS support</strong></p><p>The <strong>wp-api-jwt-auth</strong> plugin has the option to activate <a href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">CORs</a> support.</p><p>To enable the CORs Support edit your wp-config.php file and add a new constant called <strong>JWT_AUTH_CORS_ENABLE</strong></p><pre>define(&#39;JWT_AUTH_CORS_ENABLE&#39;, true);</pre><p>When the plugin is activated, a new namespace is added</p><pre>/jwt-auth/v1</pre><p>Also, two new endpoints are added to this namespace</p><p>Endpoint | HTTP Verb<br><em>/wp-json/jwt-auth/v1/token</em> | POST<br><em>/wp-json/jwt-auth/v1/token/validate</em> | POST</p><p><a href="https://wordpress.org/plugins/wp-cors/">WP-CORS</a>, when is activated by default any site, is allowed to make ajax request to your WordPress instance, this could be helpful while we are working locally</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CCaMT2eopBz0KtSNJyY0g.png" /></figure><p><a href="https://wordpress.org/plugins/contact-form-7/">Contact Form 7</a> by default creates for us a contact form, so we can edit it up to change field names, for this example (see image below), we are going to use 3 fields, a text* input for fullname field, email input for email field and textarea* field for message field, “*” means that field is required for this form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BTBqLqalaMI4Ovj1DkLxgQ.png" /></figure><p><a href="https://wordpress.org/plugins/members/">User Role Editor by Members — Best User, Role and Capability Management Plugin for WordPress</a> with this plugin we’ll add capabilities to a subscriber user role (example below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZetaILRLxG3UEsvznA8n6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BH96QJCr61ddy2Ulz5-A6w.png" /></figure><p>let’s create a user with a subscriber role, now you will have an email and a password to be authenticated using <a href="https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/">JWT Authentication for WP-API</a>, to create the API call to our WordPress instance I’ll use <a href="https://www.npmjs.com/package/axios">Axios</a>, and to Form validation on Reactjs I’ll use <a href="https://www.npmjs.com/package/formik">Formik</a>.</p><p>Add these dependencies to your Gatsbyjs project</p><pre>yarn add formik axios</pre><p>now go ahead and add a Formik form on your Gatsbyjs site as below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c9df7b8b8f17241cdff291eab37d960/href">https://medium.com/media/2c9df7b8b8f17241cdff291eab37d960/href</a></iframe><p>Now you can import this ContactForm component into your a Gatsbyjs project.</p><p>I hope this post was helpful for you, hope to see you in the next post, see yaa!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c68f472b0fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>