Open y4ahmad opened 3 years ago
@y4ahmad I had the same problem and needed to whitelist the /wp-json/contact-form-7/*
endpoint.
Thanks for helping @Gandhi11 :) Have you tried it @y4ahmad?
@y4ahmad I had the same problem and needed to whitelist the
/wp-json/contact-form-7/*
endpoint.
how will I whitelist the contact form can you explain?
Yo can try below code to whitelist the contact form 7 api request.
add_filter('jwt_auth_default_whitelist', 'custom_jwt_auth_default_whitelist', 10, 1); function custom_jwt_auth_default_whitelist($whitelist) { $rest_api_slug = home_url('/wp-json', 'relative'); $whitelist[] = $rest_api_slug . '/contact-form-7/'; return $whitelist; }
/wp-json/contact-form-7/*
is it on the functions.php file i will put it on the theme
/wp-json/contact-form-7/*
is it on the functions.php file i will put it on the theme
Try to put the code in a plugin. If you use the code in theme funcitons.php, it only runs in front-end calls. The rest-api could be called without front-end.
/wp-json/contact-form-7/*
is it on the functions.php file i will put it on the theme
Try to put the code in a plugin. If you use the code in theme funcitons.php, it only runs in front-end calls. The rest-api could be called without front-end.
Do you mean i should create a file on the contact form plugin and just add it there. Because i want to understand the process before i do it
@MOTY12 you must write your own plugin to add this code, that's simple. If you use the functions.php it only works in fron-end, but if you use a plugin, it will run in admin and rest-api calls too. The example below will add all contact-form-7 calls in whitelist, because de '*':
<?php
/*
Plugin Name: My Simple Plugin
Description: This is a simple plugin for WordPress.
Version: 1.0
Author: Your Name
*/
function custom_jwt_auth_default_whitelist($endpoints) {
array_push($endpoints,'/wp-json/contact-form-7/v1/*');
return $endpoints;
}
add_filter('jwt_auth_default_whitelist', 'custom_jwt_auth_default_whitelist', 10, 1);
When submitting a contact form I get an error in the console when I deactivate the plugin it starts working again I tried uninstalling and reinstalling the actual plugin functionality is working fine I am able to login using the API has anyone else had the same problem? I have left the Plugin activated if you need more info on the error just submit the form at the bottom of the home page https://chocolatebash.com/careers/
Uncaught TypeError: Cannot read property ‘replace’ of undefined