1

あなたが試して支援できるかどうか疑問に思っています。

ユーザーデータベースに投稿されている WordPress の登録フォームがあります。また、同じフォーム情報を Webhook (Zapier) に渡す必要があります。

1 つのフォームに対して 2 つのフォーム アクションを使用できないことは承知していますが、両方の情報を送信するための最良の方法を見つける必要があります。1 つはデータベースに、もう 1 つは Webhook リンクに。

データベースに投稿するコードの例。に投稿するにはこれが必要です

https://zapier.com/examplehook/

<form name="register_form" id="register_form<?php $template->the_instance(); ?>" action="$template->the_action_url( 'save-register' ); ?>" method="post”&gt;

onclick イベントを使用して、同時フォーム アクションも実行する JavaScript 関数を実行することを考えていました。それがうまくいくかどうかは混乱しています。

//編集されたコード

$('#registerform').validate({ // initialize the plugin
        rules: {
            first_name: {
                required: true
            },
            last_name: {
                required: true
            },
            user_email: {
                required: true,
                email: true
            },
            user_login: {
                required: true
            },
            hear_about_us: {
                required: true
            },
            contact_number: {
                required: true
            },
            address:{
                required: true
            },
            post_code: { 
                required: true
            }
        },
        submitHandler: function (form) {
            $('#registerform').on('submit', function(event) {
                event.preventDefault();

                var xhr1 = $(this).ajaxSubmit({url: 'https://zapier.com/example-hook/'}).data('jqxhr');
                var xhr2 = $(this).ajaxSubmit({url: '/register/'}).data('jqxhr');


                $.when(xhr1, xhr2).then(function() {

                    window.location.replace("/register-step2/");

                }, function() {
                    // error occured
                });
            });
        }
    });

どんな提案も理想的です!

ありがとう

4

1 に答える 1