我正在使用 Divi、ACF 和 Hubspot。
我有一个 hubspot 表单,添加到 Divi 的代码模块中,可重定向到我客户站点上的门控内容。我希望客户能够在后端使用 ACF 字段更改 URL,而不必深入研究代码。
我可以看到 ACF 字段 URL 可用,因为我可以将它附加到按钮。
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>
<script>
hbspt.forms.create({
region: "XXX",
portalId: "XXX",
formId: "XXX",
onFormSubmit: function($form) {
Cookies.set('hs_form_check', 'yes', { expires: 365 });
// This will set a cookie with 'hs_form_check' and value 'yes'
// It will expire in 365 days (you may want to make that higher or lower).
setTimeout( function() {
var formData = $form.serialize();
window.location = "'" + get_field('gated_content_url') + "'";
// ****************** THIS ONE WORKS ***************************
// window.location = "https://www.google.com";
}, 300 ); // Redirects to url with query string data from form fields after 300 milliseconds.
}
});
</script>
我的代码在使用绝对 URL 时有效(已注释掉),但我正在尝试将 ACF 字段作为重定向 URL 提供。