コンタクトフォーム7入力で記事作成した際の文字化け
-
現在、コンタクトフォーム7で作成したフォームから投稿を行うと自動的に記事の下書きが行われるようにカスタマイズを行っており、無事に反映するようにはなったのですが、フォーム入力がセレクトボックスの個所のみ【[“\u5ca1\u5c71\u770c”]】のように日本語のみUnicode(?)に変換されてしまい、解決策が見つからず困っています。
詳しい方がおられましたら、普通のテキストで書き出されるようにするにはどうすればよいか、ご教示いただけますと幸いです。
何卒よろしくお願い致します。
//フォーム送信時にブログ投稿をおこなう function wpcf7_insert_post(\WPCF7_ContactForm $contactForm) { //送信情報を取得 $submission = WPCF7_Submission::get_instance(); $form_id = $contactForm->id(); if($submission && $form_id == "40") { $formdata = $submission->get_posted_data(); $uploaded_files = $submission->uploaded_files(); $uploaded_files2 = $submission->uploaded_files(); $uploaded_files3 = $submission->uploaded_files(); $uploaded_files4 = $submission->uploaded_files(); $uploaded_files5 = $submission->uploaded_files(); $new_post = array( 'post_type' => 'user-report', 'post_title' => $formdata['ttl'], 'post_status' => 'draft', //下書き 'post_content' => $formdata['your-txt'] ); //ブログ作成 $post_id = wp_insert_post($new_post); //作成に成功した場合 if(!is_wp_error($post_id)) { //カテゴリを取得 $item1 = $formdata['product-select1']; $item_id1 = get_term_by('name', $item1 ,'use_item'); //ターム登録 wp_set_object_terms($post_id,$data['use_item'],$item_id1); //カスタムフィールドのデータも登録する add_post_meta($post_id, 'name', $formdata['your-handlename']); add_post_meta($post_id, 'date', $formdata['date']); add_post_meta($post_id, 'time', $formdata['time']); add_post_meta($post_id, 'field', $formdata['area1'] ); add_post_meta($post_id, 'field1', $formdata['area2']); add_post_meta($post_id, 'item1', $formdata['product-select1']); add_post_meta($post_id, 'item2', $formdata['product-select2']); add_post_meta($post_id, 'item3', $formdata['product-select3']); /* 画像の設定 */ if (isset($uploaded_files['img1'])) { $thumb_path = '/user-report/' . str_replace($baseurl, '', $uploaded_files['img1']); $thumb_id = addAttachmentFromForm($thumb_path, $uploaded_files['img1'], $post_id, $time); update_field('img1', $thumb_id, $post_id); } if (isset($uploaded_files2['img2'])) { $thumb_path = '/user-report/' . str_replace($baseurl, '', $uploaded_files['img2']); $thumb_id = addAttachmentFromForm($thumb_path, $uploaded_files['img2'], $post_id, $time); update_field('img2', $thumb_id, $post_id); } if (isset($uploaded_files3['img3'])) { $thumb_path = '/user-report/' . str_replace($baseurl, '', $uploaded_files['img3']); $thumb_id = addAttachmentFromForm($thumb_path, $uploaded_files['img3'], $post_id, $time); update_field('img3', $thumb_id, $post_id); } } } } add_action('wpcf7_mail_sent', 'wpcf7_insert_post', 10, 1); /* 画像処理 */ function addAttachmentFromForm($filename, $file_base, $post_id, $time) { $layout_img_value = ''; $filetype = wp_check_filetype( basename( $filename ), null ); $wp_upload_dir = wp_upload_dir(); $upfile = $wp_upload_dir['url'] . '/' . $time . basename( $filename ); $copyfile = $wp_upload_dir['path'] .'/' . $time . basename( $filename ); copy($file_base, $copyfile); $attachment = array( 'guid' => $upfile, 'post_mime_type' => $filetype['type'], 'post_title' => preg_replace( '/.[^.]+$/', '', basename( $upfile ) ), 'post_content' => '', 'post_status' => 'inherit' ); $attach_id = wp_insert_attachment( $attachment, $copyfile, $post_id ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); $attach_data = wp_generate_attachment_metadata( $attach_id, $copyfile ); wp_update_attachment_metadata( $attach_id, $attach_data ); if($attach_id) return $attach_id; else return false; } ?>
2件の返信を表示中 - 1 - 2件目 (全2件中)
2件の返信を表示中 - 1 - 2件目 (全2件中)
- トピック「コンタクトフォーム7入力で記事作成した際の文字化け」には新たに返信することはできません。