contact-form-7 相关问题

“联系表格7”是一个WordPress联系表格插件。它可以管理多个联系表单,可自定义,支持Ajax支持的提交,CAPTCHA,Akismet垃圾邮件过滤等。

提交联系表 7 时继承 ACF 字段

只是简单说明;目前,我有一个网站,员工可以登录并提交表格来请求服务。每个员工都有一个使用 ACF 字段创建的唯一 ID 字段。我什么

回答 1 投票 0

Contactform7 防止重复字段值提交

我正在使用 WordPress 3.8 和带有联系表单 7 数据库扩展的联系表单 7 插件。 我想检查现有的电子邮件,我在functions.php中的钩子上提交(alter_wpcf7_posted_data)作为...

回答 6 投票 0

联系表格 7:验证包含多个地址的电子邮件字段

我希望能够使用表单中的输入字段获取电子邮件地址,将电子邮件从 CF7 表单发送给多个收件人。问题是 CF7 的电子邮件字段仅有效...

回答 1 投票 0

在邮件发送钩子响应之前将用户发送到在 Contactform7 中获取的动态 URL

我的 function.php 文件中有一个 cf7 和一个钩子,如下所示。我想将用户发送到我将在该挂钩中收到的动态 URL。 add_action('wpcf7_before_send_mail', 'send_order_data_to_api'...

回答 1 投票 0

联系表格 7 以自定义帖子类型

我想将联系表单 7 中的联系表单处理为自定义帖子类型。 目前,这就是我所拥有的: 我想将联系表单 7 中的联系表单处理为自定义帖子类型。 目前,这就是我所拥有的: <?php if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "front_post") { //store our post vars into variables for later use //now would be a good time to run some basic error checking/validation //to ensure that data for these values have been set $title = $_POST['title']; $content = $_POST['content']; $Interest = $_POST['Interest']; $post_type = 'purchase'; //the array of arguements to be inserted with wp_insert_post $new_post = array( 'post_title' => $title, 'post_content' => $content, 'tags_input' => $tags, 'posted_data' => $Interest, 'post_status' => 'publish', 'post_category' => array('0',$_POST['cat']), 'post_type' => $post_type ); //insert the the post into database by passing $new_post to wp_insert_post //store our post ID in a variable $pid //we now use $pid (post id) to help add out post meta data $pid=wp_insert_post($new_post); //we now use $pid (post id) to help add out post meta data add_post_meta($pid, 'cust_key', $custom_field); } ?> 这里是实际表格的链接:http://stage.icardpromotions.com/create-purchase-order/ 我需要能够将此表单中的所有信息提取到自定义帖子类型“购买”中 如您所见,我目前正在拉入 post_content、post_title 等。 我还尝试通过输入名称“兴趣”从内容表单中提取内容,但它不起作用。 有人知道如何做到这一点吗? function save_posted_data( $posted_data ) { $args = array( 'post_type' => 'post', 'post_status'=>'draft', 'post_title'=>$posted_data['your-name'], 'post_content'=>$posted_data['your-message'], ); $post_id = wp_insert_post($args); if(!is_wp_error($post_id)){ if( isset($posted_data['your-name']) ){ update_post_meta($post_id, 'your-name', $posted_data['your-name']); } // if( isset($posted_data['your-email']) ){ // update_post_meta($post_id, 'your-email', $posted_data['your-email']); // } // if( isset($posted_data['your-subject']) ){ // update_post_meta($post_id, 'your-subject', $posted_data['your-subject']); // } if( isset($posted_data['your-message']) ){ update_post_meta($post_id, 'your-message', $posted_data['your-message']); } //and so on ... return $posted_data; } } add_filter( 'wpcf7_posted_data', 'save_posted_data' ); --------------------解释它------------------------- 首先创建函数并添加一个钩子 wpcf7_posted_data ---第一步--- function save_posted_data( $posted_data ) { } add_filter( 'wpcf7_posted_data', 'save_posted_data' ); ---第二步--- 现在您需要向需要使用 wp_insert_post(); 填充的帖子添加一些参数 $args = array( 'post_type' => 'post', 'post_status'=>'draft', 'post_title'=>$posted_data['your-name'], 'post_content'=>$posted_data['your-message'], ); $post_id = wp_insert_post($args); ---第三步--- 检查填写的项目是否错误 if(!is_wp_error($post_id)){ //do ur stuffs } ---第四步--- 现在检查是否设置字段并更新元数据 例如帖子 if( isset($posted_data['your-name']) ){ update_post_meta($post_id, 'your-name', $posted_data['your-name']); } 最后返回值 return $posted_data; 完整代码在上面。 这里有一个关于如何使用您自己的代码实现上述目标的快速提示,首先注册您的自定义帖子 add_action('init', 'my_custom_post'); function (){ $args = array( /*post type registration parameters*/ ); register_post_type( 'my_custom_post', $args ); } 接下来,您想要捕获您发布的数据并创建新帖子 add_filter( 'wpcf7_posted_data', 'save_posted_data' ); function save_posted_data( $posted_data ) { $args = array( 'post_type' => 'my_custom_post', /*other default parameters you want to set*/ ); $post_id = wp_insert_post($args); if(!is_wp_error($post_id)){ if( isset($posted_data['form-field-name']) ){ update_post_meta($post_id, 'form-field-name', $posted_data['form-field-name']); } //and so on ... return $posted_data; } 虽然此线程中获得最多支持的答案有效,但它有一些缺陷。 首先是:如果您从提交按钮中删除“禁用”标签,您仍然可以提交表单,从而在 WordPress 中创建帖子。所以你基本上可以绕过验证。 我遇到的第二个问题可能是特定于我的用例的,因为此函数会在网站上提交任何 cf7 表单时触发。如果您有多个 cf7 表单,即使用户以某种完全不同的表单提交某些内容,这也会创建帖子。 为了解决第一个问题,我认为最好的方法是将自定义函数挂钩到“wpcf7_before_send_mail”而不是“wpcf7_posted_data” 解决第二个问题是检查您希望触发效果的表单的 id。 这就是我解决这些问题的方法: function save_cf7_data_to_cpt( $contact_form ) { if( $contact_form->id() !== $my_form_id ) return; //dont run the rest if it is not the form you want it to be, $my_form_id we look up in admin or shortcode... $submission = WPCF7_Submission::get_instance(); if ( $submission ) { $posted_data = $submission->get_posted_data(); } //we get to $post_data in this way since it is not provided like in the wpcf7_posted_data approach $args = array( 'post_type' => 'testemonial', 'post_status'=>'draft', 'post_title'=>$posted_data['your-name'], 'post_content'=>$posted_data['your-message'], ); $post_id = wp_insert_post($args); if(!is_wp_error($post_id)){ if( isset($posted_data['your-name']) ){ update_post_meta($post_id, 'your-name', $posted_data['your-name']); } if( isset($posted_data['your-message']) ){ update_post_meta($post_id, 'your-message', $posted_data['your-message']); } //and so on ... return $posted_data; } } add_filter( 'wpcf7_before_send_mail', 'save_cf7_data_to_cpt' ); //hook into wpcf7_before_send_mail to ensure validation is ok Can u also use add_action('wpcf7_mail_sent','save_my_form_data_to_my_cpt'); add_action('wpcf7_mail_failed','save_my_form_data_to_my_cpt'); function save_my_form_data_to_my_cpt($contact_form){ $submission = WPCF7_Submission::get_instance(); if (!$submission){ return; } $posted_data = $submission->get_posted_data(); //The Sent Fields are now in an array //Let's say you got 4 Fields in your Contact Form //my-email, my-name, my-subject and my-message //you can now access them with $posted_data['my-email'] //Do whatever you want like: $new_post = array(); if(isset($posted_data['your-name']) && !empty($posted_data['your-name'])){ $new_post['post_title'] = $posted_data['your-name']; } else { $new_post['post_title'] = 'Message'; } $new_post['post_type'] = 'inquiry'; //insert here your CPT if(isset($posted_data['tel-901'])){ $new_post['post_content'] = $posted_data['tel-901']; } else { $new_post['post_content'] = 'No Message was submitted'; } $new_post['post_status'] = 'publish'; //you can also build your post_content from all of the fields of the form, or you can save them into some meta fields if(isset($posted_data['your-email']) && !empty($posted_data['your-email'])){ $new_post['meta_input']['sender_email_address'] = $posted_data['your-email']; } if(isset($posted_data['checkbox-674']) && !empty($posted_data['checkbox-674'])){ //$new_post['meta_input']['sender_name'] = $posted_data['checkbox-674']; $ChildSeat=$posted_data['checkbox-674']; $Child_Seat=''; for($a=0;$a<count($ChildSeat);$a++) { $data['checkbox-674']=$_POST['checkbox-674'][$a]; $Child_Seat.=$data['checkbox-674'].'<br>'; $new_post['post_content'] = $Child_Seat; } } //When everything is prepared, insert the post into your Wordpress Database if($post_id = wp_insert_post($new_post)){ //Everything worked, you can stop here or do whatever } else { //The post was not inserted correctly, do something (or don't ;) ) } return; } 有一个插件可以执行此操作,发布我的 CF7 表单。 该插件允许您将 CF7 表单及其字段映射到现有帖子类型或新的自定义帖子类型。 映射过程是使用交互式 UI 管理页面完成的,您可以选择将字段映射到帖子字段(标题、内容、摘录、slug、作者)以及帖子元字段。 此外,该插件还引入了save提交按钮,允许用户保存表单的草稿版本,这对于大型复杂表单尤其有用。 该插件可以自动加载已映射到该分类的select/checkbox/radio字段中的分类术语,从而使创建的帖子能够自动分配给用户选择的术语。 该插件有多个钩子和过滤器来定制流程。 发布我的 CF7 表格工作正常,但有时功能图像和选择不起作用。

回答 6 投票 0

禁用选择的多个选项中的一个选项

我使用插件联系表 7 创建了一个联系表。 我的问题是我想从选择的多个选项中禁用一个选项。 这是我的代码: [选择事件类:form-control”

回答 3 投票 0

如何以编程方式在联系表单 7 中添加自定义消息

以编程方式在联系表 7 中发送自定义消息之前,我无法在电子邮件正文中发送自定义消息。 这是我在functions.php中编写的代码 add_action( 'wpcf7_mail', '

回答 1 投票 0

回复通过联系表 7 发送的电子邮件,转到四个不同的电子邮件

当用户在我的网站上填写联系表格时,就会向他们发送一封电子邮件。 我希望对此发送的电子邮件所做的任何回复也转发到 4 个不同的电子邮件。 我尝试过使用“Addit...

回答 1 投票 0

使用 Apache(htaccess) 和 php 7 联系 Form 7 WordPress 插件 - 未找到与 URL 和请求方法匹配的路由

访问 https://EXAMPLE.com/wp-json/contact-form-7/v1/contact-forms/5/feedback 我收到错误: { “代码”:“rest_no_route”, “message”:“未找到匹配的路线...

回答 2 投票 0

如何编辑Contact Form 7操作URL?

我正在尝试将操作 URL 更改为外部 URL 以将我的帖子数据发送到。我目前正在使用下面的代码片段来执行此操作。我正在尝试将 POST 数据发送到 google app-script。我...

回答 1 投票 0

联系表格7导致HTTP 500错误

没有人能够提交表单,我查看了一下,收到了 POST 500 内部服务器错误。 邮政 http://carlsbad4rent.com/wp-json/contact-form-7/v1/contact-forms/321/feedback 500(

回答 5 投票 0

如何使用联系表单7捕获POST数据

我的functions.php中有这个钩子: add_action( 'wpcf7_mail_sent', 'myfunction' ); 我想在发送表单时发布这些值。 我有一个这样的字段:[textarea your-message]。 我该怎么办

回答 5 投票 0

更改联系表单 7 中“选择文件”按钮的文本(WordPress)

文件上传字段由浏览器控制,因此应根据浏览器设置自动翻译。我需要在此按钮上设置我的语言。我怎样才能做到这一点?

回答 3 投票 0

联系表 7 的条件自动回复

尝试根据输入字段中的内容实现联系表单 7 的有条件自动回复。该帖子(有条件自动回复器是联系表格 7)提出了一个解决方案,...

回答 2 投票 0

联系表格 7 复选框,带有写入文本的选项

我需要使用联系表单7插件制作一个表单,并获得一个复选框列表,以便能够与其他人一起做出最后一个选项:,如果选中它,则能够输入文本..我可以真的不是

回答 2 投票 0

如何使 Bootstrap 5 浮动标签在联系表 7 中工作?

我无法使用新的表单功能,联系表单 7 (Wordpress) 中的浮动标签 (Bootstrap 5),问题是当在标签内添加标签时它会中断,我想,idk。 引导温度...

回答 3 投票 0

如何自动填写联系表7

在我的网站上,我使用联系表 7 将价目表发送给我们的潜在客户。他们只需要填写姓名和电子邮件即可。如果他们想预订我们的服务,客户只需点击...

回答 4 投票 0

如何格式化 - 添加空格 - 联系表格 7 中的数字和电话号码输出数据 - Wordpress

我使用 WordPress 中的 Contact Form 7 插件在联系表单中设置了几个字段。其中一个字段是电话号码字段。当人们输入电话号码时,除非他们

回答 1 投票 0

当类存在时,如何删除联系表单 7 中的跨度包装?

我试图将标签元素放入“wpcf7-form-control-wrap”范围中,但我只希望在“浮动”类添加到父 div 时完成此操作。 我正在使用以下解决方案:ht...

回答 1 投票 0

根据CF7中的下拉选择发送不同的电子邮件模板

我正在尝试制作一个表格,首先要求提供用户数据,然后发送一封包含下载我们目录的链接的电子邮件。该案例的特殊性在于客户必须选择他的业务...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.