Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mw-wp-form action_hook example "mwform_before_send_admin_mail", "mwform_enqueue_scripts"
/**
* MW WP FORM フォームから記事を下書き保存するサンプル。
*/
function my_mwform_savedraft($mail, $data) {
// POSTデータを取得
$post = array(
'post_title' => $data["your-name"],
'post_content' => $data["your-message"],
'post_status' => 'draft',
'post_type' => 'post'
);
$id = wp_insert_post($post);
}
add_action( 'mwform_before_send_admin_mail_mw-wp-form-XXXXX', 'my_mwform_savedraft', 10, 2 );
/**
* mw-wp-form に Ajaxzip3のJSを読み込む。(for日本郵便)
*/
function my_mwform_enqueue_scripts() {
wp_enqueue_script( 'ajaxzip3','https://ajaxzip3.github.io/ajaxzip3.js');
}
add_action( 'mwform_enqueue_scripts_mw-wp-form-XXXXX', 'my_mwform_enqueue_scripts');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.