• adrienikadia

    (@adrienikadia)


    Hello,

    I’m reaching out because your plugin was not working properly on one of our client’s websites. I have patched the issue.

    The filter add_filter( ‘wpcf7_form_elements’, [ $this, ‘inject_hidden_fields’ ], 20, 2 ) no longer passes the second parameter $form. It therefore needs to be retrieved differently. I patched it as follows:

    if ( ! $form ) {
    $form = WPCF7_ContactForm::get_current();
    if ( ! $form ) {
    return $content;
    }
    }

    Additionally, would it be possible to add “gclid” to the supported fields? I added it on my end in several places across the arrays and the JS. The main change being in inject_hidden_fields:

    foreach ( [ ‘source’, ‘medium’, ‘campaign’, ‘id’, ‘term’, ‘content’, ‘gclid’ ] as $key ) {
    $name = str_starts_with( $key, ‘utm_’ ) || $key === ‘gclid’ ? $key : ‘utm_’ . $key;
    $fields .= ‘<input type=”hidden” name=”‘ . esc_attr( $name ) . ‘” class=”utm utm_’ . esc_attr( $key ) . ‘” value=”” />’ . “\n”;
    }

    For better portability, it would also be worth considering adding custom filters.

    Thank you in advance.

    Best regards,

You must be logged in to reply to this topic.