Skip to content

Submitting Cloudflare turnstile token #451

Answered by joezappie
joezappie asked this question in Q&A
Discussion options

You must be logged in to vote

@justlevine Thank you!!! That was almost perfect for being written on a phone lol, heres my final changes incase some one else comes across this. I'll make a pull request with the turnstile addon to hopefully get this supported out of the box.

add_filter(
    'graphql_gf_field_value_input_prepared_value',
    static function ($value, $args, $field) {
        if ($field instanceof \GF_Field_Turnstile) {
            // Inject the turnstile token into the post data
            $_POST['cf-turnstile-response_' . $field->formId] = sanitize_text_field($value);
        }
        return $value;
    },
    10,
    3
);

add_action('graphql_register_types', function () {

    // Create a Turnstile f…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@justlevine
Comment options

@joezappie
Comment options

Answer selected by justlevine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants