• I am trying to understand the sequence of using a querystring value in a Contact Form 7 form like this:
    [text* your-name default:get]
    I see the below PHP code functions properly but the value display in the form is not the value that is set by it. On the form I see whatever the original querystring value was.

    So if I put in ?your-name=123456
    The PHP displays 123456 and then 12345 but on the form it displays 123456

    add_action('wp_footer', 'debug_cf7_default_get');
    function debug_cf7_default_get() {
    if (isset($_GET['your-name'])) {
    $original_worker = $_GET['your-name'];
    console_log("Original worker value: " . $original_worker);
    $worker = sanitize_text_field($_GET['your-name']);
    $worker = wp_kses_post($worker); // For more robust sanitization
    // Adjust the regular expression as needed
    $worker = preg_replace('/[^A-Za-z0-9_-]/', '', $worker);
    // Remove character limit if necessary
    $worker = substr($worker, 0, 5);
    console_log("Sanitized and truncated worker value: " . $worker);
    $_GET['your-name'] = $worker;
    }
    }
    function console_log($output, $with_script_tags = true) {
    $js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT) . ');';
    if ($with_script_tags) {
    $js_code = '';
    }
    echo $js_code;
    }

    I thought that by setting the new value in the code, it would reflect all around. But is the form somehow geting that value beforehand? Or getting it some other way?

    Is there a way for me to get the querystring value, process it and assign it a new value, and then have that value be what is used by Contact Form 7?

    Thank you

  • You must be logged in to reply to this topic.