[英]wordpress form plugin that allows to give a custom url in form action
我正在搜索允許管理員創建表單並將該表單提交到自定義網址的wordpress插件。 我使用了聯系表格7,但不允許此類功能。
我發現的唯一解決方案是,要么創建自定義表單,要么使用聯系表單7鈎子來獲取帖子數據,並通過curl調用將該數據發送到自定義網址。
有更好的解決方案嗎?
使用了這個小忍者鈎子,但不起作用:
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' );
}
}
在這里,我使用聯系表格7給出了兩種方法
方式1通過聯系表單自定義操作網址
在您的站點根文件夾中創建“ custom_url.php”文件。在此文件中,您可以獲取聯系表單的發布數據,並編寫您的curl代碼以及所需的任何內容。
復制以下代碼並粘貼到您的主題function.php文件中
add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url'); function wpcf7_custom_form_action_url() { return 'custom_url.php'; }
給此文件“ custom_url.php”以聯系表單操作。 復制以下代碼,並將其粘貼到您的頁面中,或張貼在任何您想要的地方。
<form class =“” action =“ custom_url.php” method =“ post” name =“”>
[contact-form-7 id =“ 1” title =“聯系表格7”]
</ FORM>
方式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 */
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.