Last active
April 4, 2023 13:21
-
-
Save tomothumb/92c516f9ee9858994fec to your computer and use it in GitHub Desktop.
mw-wp-form action_hook example "mwform_before_send_admin_mail", "mwform_enqueue_scripts"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 ); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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