2017-04-24 27 views
1

我正在尋找一個wordpress插件,允許管理員創建表單並將該表單提交到自定義url。我使用聯繫表單7,但它不允許這種類型的功能。wordpress表單插件,允許在表單動作中提供自定義url

我發現的唯一解決方案是創建自定義表單或使用聯繫表單7鉤子來獲取發佈數據並通過捲髮調用將該數據發送到自定義網址。

請更好的解決方案??

使用這個小忍者掛鉤,但不工作:

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'); 
    }  
} 

回答

0

這應該做的伎倆CF7 Docs

僅將代碼添加到聯繫頁面模板的頁腳。

讓我知道你如何繼續。

2

這裏我以聯繫表7

路-1通過接觸形式的自定義操作URL給出兩種方式

  1. 創建站點根「custom_url.php」文件文件夾 在這個文件中,你可以得到聯繫表格發佈數據,並編寫你的捲髮代碼和任何你想要的。

  2. 複製下面的代碼並粘貼到你的主題function.php文件

    add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url'); 
    function wpcf7_custom_form_action_url() 
        { 
         return 'custom_url.php'; 
        } 
    
  3. 給這個文件「custom_url.php」聯繫表單操作。複製下面的代碼並將其粘貼到您的頁面或帖子中,無論您想要什麼。

    <形式類= 「」 行動= 「custom_url.php」 方法= 「POST」 名稱= 「」 >
    [接觸形式-7- ID = 「1」 標題= 「接觸形式7」]
    < /形式>

分路-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 */ 

    } 
}