【问题标题】:How to fixed this error in Contact Form & multi step如何在联系表格和多步骤中修复此错误
【发布时间】:2017-06-06 07:23:12
【问题描述】:

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

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

错误:

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

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

【问题讨论】:

  • 说上一个按钮,是表单的上一个按钮还是浏览器的后退按钮?您的浏览器地址栏的 URL 是否被更改?
  • 这是我之前的按钮代码 [previous "Previous"]

标签: wordpress plugins contact-form-7


【解决方案1】:

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

根据author's update,插件无法正常工作。

更新:对于大多数人来说,这个插件仍然可以正常工作,但对某些人来说却不是。

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

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"]

【讨论】:

    猜你喜欢
    • 2016-04-16
    • 1970-01-01
    • 1970-01-01
    • 2020-01-20
    • 2020-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-13
    相关资源
    最近更新 更多