kennym / cf7-to-api

LOOKING FOR MAINTAINER. Wordpress plugin to transmit contact form 7 entries to remote API using POST or GET
https://wordpress.org/plugins/cf7-to-api-basic-auth/
52 stars 30 forks source link

Custom Headers #20

Closed o-data closed 4 years ago

o-data commented 4 years ago

Re: https://wordpress.org/support/topic/custom-headers-12/

Hi kennym,

How to add Custom Headers? The thread was resolves but there was not guide to doing that.

Thank you.

o-data commented 4 years ago

Hi guys,

Good news, I figured out how to do it since there were no response. Here is the guide to add your custom headers.

Go to your file manager (or make these edit before uploading to your Wordpress website). Assuming it is uploaded then make the edit to this file (this guide is applicable to version 1.4.6 only, I think it general work for all version).

\wp-content\plugins\cf7-to-api-basic-auth\includes\class-cf7-api-admin.php

Around lines 561 you should see this code:

      if( $record_type == "json" ){

        $args['headers']['Content-Type'] = 'application/json';

Now I want to add another custom headers in here, I would change from up to this:


      if( $record_type == "json" ){

        $args['headers']['Content-Type'] = 'application/json';
        $args['headers']['Accept'] = 'application/json';

Save file, do a test and see if it work. For me it did because my server require that "Accept" header.

I close this now since issue is resolve.