• Resolved JohnLauber

    (@johnlauber)


    Is there a way to get a value from a form field that’s not using a CF7 shortcode?

    I tried a snippet that I found in another support ticket:

    function vadimpopowsky_ctz_get_data_from_contact_form( $data, $contact_form ) {
    $tags = $contact_form->scan_form_tags();

    foreach ( $tags as $tag ) {
    if ( in_array( $tag->type, array( ‘quote-list’ ) ) ) {
    $quotelist = $tag->name;

    $data[‘quote-list’] = ( isset( $_POST[ $quotelist ] ) ) ? sanitize_text_field( $_POST[ $quotelist ] ) : ”;
    }
    }

    return $data;
    }

    add_filter( ‘ctz_get_data_from_contact_form’, ‘vadimpopowsky_ctz_get_data_from_contact_form’, 10, 2 );

    However, the “quote-list” in this case didn’t make it to Zapier. My field is hidden with a textarea value and I know it gets picked up by CF7 but I can’t get it to Zapier.

    Here’s my form html:

    <textarea name=”quote-list” cols=”40″ rows=”10″ class=”wpcf7-form-control wpcf7-textarea” aria-invalid=”false”> ****************************************************

    FP 101 Contemporary Fireplace SKU:FP 101 | 1

    ****************************************************
    </textarea>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mário Valney

    (@mariovalney)

    Hi! Thanks for using our plugin.

    1 – Your field is a textarea, so we should replace sanitize_text_field by sanitize_textarea_field.

    2 – The code you got is about not-CF7 default tags. We can try:

    function vadimpopowsky_ctz_get_data_from_contact_form( $data, $contact_form ) {  
        $data['quote-list'] = ( ! empty( $_POST['quote-list'] ) ) ? sanitize_textarea_field( $_POST['quote-list'] ) : '';
    
        return $data;
    }
    
    add_filter( 'ctz_get_data_from_contact_form', 'vadimpopowsky_ctz_get_data_from_contact_form', 10, 2 );
    Thread Starter JohnLauber

    (@johnlauber)

    Thank you, very much. That worked.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Getting value without shortcode’ is closed to new replies.