首页 > 解决方案 > 表单提交后设置cookie

问题描述

我正在使用 Popup Maker 和 Hubspot 表单。我将 HS 表单简码放入弹出窗口中,并尝试在表单提交时手动创建 cookie,但我的代码不起作用?谁能看到我做错了什么?我能够从 Popup Maker 文档中获得以下代码,并且我输入了自己的弹出制作者 ID 和 hubspot 表单的类。

add_action( 'wp_footer', 'my_custom_popup_scripts', 500 );
/**
 *  Close a popup by targeting a specific HTML element within a popup container.
 *
 * @since 1.0.0
 *
 * @return void
 */
function my_custom_popup_scripts() { ?>
    <script type="text/javascript">
        (function ($, document, undefined) {

            jQuery('#popmake-1070').on('.hs-button.primary, input[type="submit"], input[type="button"]', function () {
                jQuery.pm_cookie(
                    'pum-1070', // The cookie name that is checked prior to auto opening.
                    true, // Setting a cookie value of true.
                    '10 years', // Plain english time frame.
                    '/' // Cookie path of '/' means site wide.
                );
            });

        }(jQuery, document))
    </script><?php

标签: cookiespopuphubspot

解决方案


推荐阅读