json - 通过 JSON REST API (WP API) 联系表单 7?

标签 json angularjs wordpress

这可能吗?

获取表单(字段输入类型等)的JSON ( plugin url ) .) 我该如何将其连接到插件中?

然后,要使用plugin的发送机制,我如何将其余的POST传输到plugins发送功能?

任何想法将不胜感激

最佳答案

您可以 Hook wpcf7_before_send_mail 操作以在 CF7 发送的邮件之前获取 POST 数据。

add_action('wpcf7_before_send_mail', 'my_wpcf7_choose_recipient');    
function my_wpcf7_choose_recipient($WPCF7_ContactForm)
{
    // use $submission to access POST data
    $submission = WPCF7_Submission::get_instance();
    $data = $submission->get_posted_data();
    $subject = $data['subject']

    // use WPCF7_ContactForm->prop() to access form settings
    $mail = $WPCF7_ContactForm->prop('mail');
    $recipient = $mail['recipient'];

    // update a form property
    $WPCF7_ContactForm->set_properties(array('mail' => $mail));
}

然后在这个函数中你就可以调用你的插件并传给他$submission

如果您想更改 POST 数据,可以使用 wpcf7_posted_data 过滤器:

add_filter('wpcf7_posted_data', 'my_wpcf7_posted_data');
function my_wpcf7_posted_data($data)
{
    $data['subject'] = 'Test ' . $data['subject'];
    return $data;
}

关于json - 通过 JSON REST API (WP API) 联系表单 7?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31604804/

相关文章:

javascript - 在 Release模式下第一次 ng-include 后 Angular 停止

php - 在 WooCommerce 中添加最低购物车金额的免费赠品产品

javascript - 如何在 Rails 中正确传递 JSON

ios - 如何在swift中将json字符串作为参数传递

javascript - 将事件附加到 Angular2 中的新元素

wordpress - 如何使用重写模块在 Apache 上使用不同的端口运行两个不同的技术项目

wordpress - 使用 WP-AppKit 嵌入 YouTube

javascript - 如何将父字段名称添加到json对象中新添加的行

python - 如何执行多查询 fql 语句?

javascript - 将指令与 JS 模板本身一起使用