• bob

    (@dannyotoole)


    Hi all,

    So i’m wondering is it possible to get the current url of the page the form is on. I’ve seen some stuff about special mail tags but i want to send this url in the body of the form submission.

    So I’m using webhooks that send the form data to zapier and i want to add the current page url to the submission to zapier along with the normal form data.

    Has anyone done this before?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Bob,

    simply add to “[_url]” your e-mail-text.
    See https://contactform7.com/special-mail-tags/ for further fields, you can add.

    Bfn
    Michael

    Thread Starter bob

    (@dannyotoole)

    Ye but when I send the form to zapier using webhooks with this [_url] it doesn’t send anything. I think that’s meant to be used in the mail tab yes? That’s not what im looking for.

    I want to send the current page url with all the other form field value in the form submission.

    Thread Starter bob

    (@dannyotoole)

    just an update:
    I found a stackoverflow thread. Below is creating a custom shortcode for cf7 to capture the current page url, and it works. The only problem is the cf7 webhooks dont send the current_url data to zapier, it either doesn’t show up or has no data. Do i need to append it to the form submission? or have i not registered it properly? Where am i going wrong with this?

    add_action( 'wpcf7_init', 'wpcf7_add_form_tag_current_url' );
    function wpcf7_add_form_tag_current_url() {
        // Add shortcode for the form [current_url]
        wpcf7_add_form_tag( 'current_url',
            'wpcf7_current_url_form_tag_handler',
            array(
                'name-attr' => true
            )
        );
    }
    
    // Parse the shortcode in the frontend
    function wpcf7_current_url_form_tag_handler( $tag ) {
        global $wp;
        $url = home_url( $wp->request );
        return '<input type="hidden" name="current-url" value="'.$url.'" />';
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Current Page URL’ is closed to new replies.