简体   繁体   English

wordpress表单插件,允许在表单操作中提供自定义网址

[英]wordpress form plugin that allows to give a custom url in form action

i am searching a wordpress plugin that allow admin to create a form and submit that form to a custom url. 我正在搜索允许管理员创建表单并将该表单提交到自定义网址的wordpress插件。 I used contact form 7 but it doesn't allow such type of functionality. 我使用了联系表格7,但不允许此类功能。

The only solution that i found is, either create a custom form or to use contact form 7 hooks to fetch post data and sent that data to a custom url via a curl call. 我发现的唯一解决方案是,要么创建自定义表单,要么使用联系表单7钩子来获取帖子数据,并通过curl调用将该数据发送到自定义网址。

Any better solution please?? 有更好的解决方案吗?

Used this small ninja hook, but not working: 使用了这个小忍者钩子,但不起作用:

function ninja_forms_handler() {
  add_action ( 'ninja_forms_post_process', 'change_ninja_forms_landing_page', 1, 2 );
}
add_action('init', 'ninja_forms_handler');

function change_ninja_forms_landing_page(){
    global $ninja_forms_processing; 

    $form_id = $ninja_forms_processing->get_form_ID(); 

    $ninja_forms_processing->update_form_setting( 'landing_page', 'test.php' ); 
    }     
}

Here I have given two ways by using contact form 7 在这里,我使用联系表格7给出了两种方法

Way-1 Through contact form custom action URL 方式1通过联系表单自定义操作网址

  1. Create "custom_url.php" file in your site root folder In this file you can get contact form post data and write your curl code and whatever you want.. 在您的站点根文件夹中创建“ custom_url.php”文件。在此文件中,您可以获取联系表单的发布数据,并编写您的curl代码以及所需的任何内容。

  2. Copy the below code and paste in your theme function.php file 复制以下代码并粘贴到您的主题function.php文件中

      add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url'); function wpcf7_custom_form_action_url() { return 'custom_url.php'; } 
  3. Give this file "custom_url.php" to contact form action. 给此文件“ custom_url.php”以联系表单操作。 Copy the below code and paste it in your page or post whereever you want. 复制以下代码,并将其粘贴到您的页面中,或张贴在任何您想要的地方。

    <form class="" action="custom_url.php" method="post" name=""> <form class =“” action =“ custom_url.php” method =“ post” name =“”>
    [contact-form-7 id="1" title="contact form 7"] [contact-form-7 id =“ 1” title =“联系表格7”]
    </form> </ FORM>

Way-2 Though contact form 7 hook "wpcf7_before_send_mail" 方式2尽管联系表7勾有“ wpcf7_before_send_mail”

add_action('wpcf7_before_send_mail', 'CF7_pre_send');

function CF7_pre_send($cf7) {
    $submission = WPCF7_Submission::get_instance();

    if ($submission) {
        $posted_data = $submission->get_posted_data();
        $arrFields = array();
        foreach ($posted_data as $key => $value) {
            //$strKeyVals .= $key.":".$value.", ";
            if ("_wp" != substr($key, 0, 3)) {
                $arrFields[] = $key . '${$' . $value;
            }
        }
/* Here you can write curl and whatever you want */

    }
}

This should do the trick CF7 Docs . 这应该可以解决CF7 Docs的问题

Add the code to the footer of your Contact page template only. 仅将代码添加到“联系人”页面模板的页脚中。

Let me know how you get on. 让我知道你是怎么办的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM