如何修复联系表和多步骤中的此错误

How to fixed this error in Contact Form & multi step

我在 wordpress 中使用 Contact form Multi Step 插件,我有 5 个表单,每次我按上一个按钮时它都不会重定向到上一个表单

大家好,每次我按上一个按钮时都会出现错误:

错误:

    {"code":"rest_no_route","message":"No route was found matching the URL and 
    request method","data":{"status":404}}

补充: 每次我提交感谢信息都会出现

下面的答案是对 WordPress v4.7.5 上的 Contact Form 7 Multi-Step Forms v2.1 错误的非官方修复。

根据 author's update.

插件不再正常工作

UPDATE: This plugin still works as expected for most people, but it does not for some.

要解决此问题,您必须编辑插件的一些代码。

wp-content/plugins/contact-form-7-multi-step-module/form-tags/module-back.php 中更新此函数。

/**
 * Handle the back form shortcode.
 */
function cf7msm_back_shortcode_handler( $tag ) {
    if (!class_exists('WPCF7_Shortcode') || !function_exists('wpcf7_form_controls_class'))
        return;
    $tag = new WPCF7_Shortcode( $tag );

    $class = wpcf7_form_controls_class( $tag->type );

    $atts = array();

    $atts['class'] = $tag->get_class_option( $class );
    $atts['id'] = $tag->get_id_option();
    $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );

    $value = isset( $tag->values[0] ) ? $tag->values[0] : '';
    $previous_url = isset( $tag->values[1] ) ? $tag->values[1] : '.';
    if ( empty( $value ) ) {
        if ( $tag->type == 'previous') {
            $value = __( 'Previous', 'contact-form-7-multi-step-module' );
        }
        else {
            //using old version
            $value = __( 'Back', 'contact-form-7-multi-step-module' );
        }
    }

    $atts['type'] = 'button';
    $atts['value'] = $value;
    $atts['href'] = $previous_url;

    $atts = wpcf7_format_atts( $atts );

    $html = sprintf( '<input %1$s />', $atts );

    return $html;
}

并在 wp-content/plugins/contact-form-7-multi-step-module/resources/cf7msm.js 更改

中更新 1 行
window.location.href = val[step_field.val()];

window.location.href = $(this).attr('href');

最后,您需要更改在联系表单中插入 [previous] 标签的方式。进行上述更改后,[previous] 标记将像这样工作。

[previous "Button Label" "URL of previous step"]