Coder Social home page Coder Social logo

Comments (8)

Gandhi11 avatar Gandhi11 commented on August 28, 2024

@y4ahmad I had the same problem and needed to whitelist the /wp-json/contact-form-7/* endpoint.

from jwt-auth.

contactjavas avatar contactjavas commented on August 28, 2024

Thanks for helping @Gandhi11 :)
Have you tried it @y4ahmad?

from jwt-auth.

MOTY12 avatar MOTY12 commented on August 28, 2024

@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?

from jwt-auth.

seqnetworks avatar seqnetworks commented on August 28, 2024

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;
}

from jwt-auth.

MOTY12 avatar MOTY12 commented on August 28, 2024

/wp-json/contact-form-7/*

is it on the functions.php file i will put it on the theme

from jwt-auth.

pesseba avatar pesseba commented on August 28, 2024

/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.

from jwt-auth.

MOTY12 avatar MOTY12 commented on August 28, 2024

/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

from jwt-auth.

pesseba avatar pesseba commented on August 28, 2024

@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);

from jwt-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.