Viewing 7 replies - 1 through 7 (of 7 total)
  • I have the same problem using Polylang plugin.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Can I see the site?

    Thread Starter Ryan Sechrest

    (@sovereign)

    I temporarily put back one of the contact forms for you to see: https://fleishmanhillard.de/contact/general-inquiries/?lang=en

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Okay. It’s obviously WPML’s problem. Wait for them to fix it.

    Thread Starter Ryan Sechrest

    (@sovereign)

    So you’re saying when CF7 builds the URL to submit the contact form via ajax, it builds it correctly without the query string, but you saw WPML add it prior to submission?

    Or is that query string already present when CF7 builds the URL?

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    The API route URL is built with this function call:

    rest_url( 'contact-form-7/v1' )

    This is the correct output:

    https://fleishmanhillard.de/wp-json/contact-form-7/v1

    This is what you see when WPML interferes:

    https://fleishmanhillard.de/wp-json/?lang=en/contact-form-7/v1

    Thread Starter Ryan Sechrest

    (@sovereign)

    I solved it by adding a filter to the REST URL that moves the query string to the end.

    add_filter('rest_url', function($url) {
        $result = preg_match('/(\?.+)\//U', $url, $matches);
        if (!$result || !isset($matches[0]) || !isset($matches[1])) {
            return $url;
        }
        $url = str_replace($matches[0], '', $url);
    
        return $url . $matches[1];
    });
    • This reply was modified 7 years, 6 months ago by Ryan Sechrest.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Contact form doesn’t submit on pages with query string’ is closed to new replies.