【发布时间】:2020-06-16 18:23:35
【问题描述】:
我正在使用带有自定义 webhook 的 Elementor 表单,但每次提交时,我都会收到“错误”消息。
在我的functions.php 文件中,我根据Forms API documentation 获得了Form New Record Action。
// A send custom WebHook
add_action( 'elementor_pro/forms/new_record', function( $record, $handler ) {
$form_name = $record->get_form_settings( 'form_name' );
if ( 'test_form' !== $form_name ) {
return;
}
$raw_fields = $record->get( 'fields' );
$fields = [];
foreach ( $raw_fields as $id => $field ) {
$fields[ $id ] = $field['value'];
}
wp_remote_post( 'https://example.com', [
'body' => $fields,
]);
}, 10, 2 );
我有“wp_remote_post”和我想将表单发布到的 URL,但它不会重定向我或其他什么,只是返回“错误”消息。
在 Elementor 编辑器上,我在提交表单后添加了 Webhook 操作
可能出了什么问题?谢谢
【问题讨论】:
-
您找到解决方案了吗?
-
@mleister 毕竟我使用了重定向操作到 Wordpress 页面。我在模板中创建了自定义 php 文件并将其用于该页面。因此,在提交表单后,我被重定向到该页面,其中包含我添加到重定向到 URL 的所有参数,如下所示:example.com/my-page/?id_widget=[field id="id"]...