Hi Mario,
thank you very much for your reply!
I saw that topic, but still it is not very clear for me.
I added this as the webhook URL:
https://api.mariner.yembo.ai/initial-params
and this to functions.php
add_filter( 'ctz_post_request_args', 'oilbanker_ctz_post_request_args' );
function oilbanker_ctz_post_request_args( $args ) {
$args['headers']['X-Landing-Page-Access-Token: my-token-here'] = 'value';
return $args;
}
now, do I need to also add something about these two?
-H ‘Content-Type: application/json’ \
-d $'
and if yes, how to add multiple headers? This way?
add_filter( 'ctz_post_request_args', 'oilbanker_ctz_post_request_args' );
function oilbanker_ctz_post_request_args( $args ) {
$args['headers']['X-Landing-Page-Access-Token: my-token-here'] = 'value';
$args['headers']['Content-Type: application/json'] = 'value';
return $args;
}
Also, is there a way I could test if it is working in the end?
Thank you!
-
This reply was modified 1 year, 2 months ago by
kpeu3e.
I guess you don’t need to add Content-Type header. And your custom header is not ok. Just add to your functions.php
:
<?php
add_filter( 'ctz_post_request_args', 'kpeu3e_ctz_post_request_args' );
function kpeu3e_ctz_post_request_args( $args ) {
$args['headers']['X-Landing-Page-Access-Token'] = 'your-value-here';
return $args;
}
The array key (X-Landing-Page-Access-Token) is the header name and the value is the header’s value.
Note: please, use code tag to make your code more readable on forum.
-
This reply was modified 1 year, 2 months ago by
Mario Valney.
Thanks, Mario.
And does the plugin provide an option to use custom JSON template, or is it only predefined?
For example if I want to exclude some fields.
Thanks.
-
This reply was modified 1 year, 2 months ago by
kpeu3e.
In the same way, you can use the ctz_get_data_from_contact_form filter to change data provided by form or even the ctz_post_request_args again.
For example:
<?php
add_filter( 'ctz_post_request_args', 'kpeu3e_ctz_post_request_args' );
function kpeu3e_ctz_post_request_args( $args ) {
$args['headers']['X-Landing-Page-Access-Token'] = 'your-value-here';
$data = json_decode( $args['body'] );
// Your code
$args['body'] = json_encode( $data );
return $args;
}
Thanks!
Great plugin and great support!