{"id":17516,"date":"2025-11-10T12:02:37","date_gmt":"2025-11-10T03:02:37","guid":{"rendered":"https:\/\/nxpg.net\/blog\/tech\/?p=17516"},"modified":"2025-11-10T12:02:38","modified_gmt":"2025-11-10T03:02:38","slug":"contact-form-7%e3%81%a7%e8%87%aa%e5%8b%95%e8%bf%94%e4%bf%a1%e3%83%a1%e3%83%bc%e3%83%ab%e3%81%ae%e4%bb%b6%e5%90%8d%e3%82%92%e5%88%86%e5%b2%90%e3%81%95%e3%81%9b%e3%82%8b%e6%96%b9%e6%b3%95%e3%80%82","status":"publish","type":"post","link":"https:\/\/nxpg.net\/blog\/tech\/?p=17516","title":{"rendered":"Contact Form 7\u3067\u81ea\u52d5\u8fd4\u4fe1\u30e1\u30fc\u30eb\u306e\u4ef6\u540d\u3092\u5206\u5c90\u3055\u305b\u308b\u65b9\u6cd5\u3002"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"960\" height=\"540\" src=\"https:\/\/nxpg.net\/blog\/tech\/wp-content\/uploads\/sites\/7\/4c273d9e7700262af1ac3813e672957e.png\" alt=\"Contact Form 7\u3067\u81ea\u52d5\u8fd4\u4fe1\u30e1\u30fc\u30eb\u306e\u4ef6\u540d\u3092\u5206\u5c90\u3055\u305b\u308b\u65b9\u6cd5\u3002\" class=\"wp-image-17602\" srcset=\"https:\/\/nxpg.net\/blog\/tech\/wp-content\/uploads\/sites\/7\/4c273d9e7700262af1ac3813e672957e.png 960w, https:\/\/nxpg.net\/blog\/tech\/wp-content\/uploads\/sites\/7\/4c273d9e7700262af1ac3813e672957e-624x351.png 624w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/><\/figure><\/div>\n\n\n<p>\u3053\u3093\u306b\u3061\u306f\uff01\u3000\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u5965\u4e95\u3067\u3059\u3002<br>\u6700\u8fd1\u3001WordPress\u306e\u30d5\u30a9\u30fc\u30e0\u4f5c\u6210\u30d7\u30e9\u30b0\u30a4\u30f3Contact Form7\uff08\u4ee5\u4e0b\u3001CF7\uff09\u3067\u5b9f\u88c5\u4f5c\u696d\u3092\u884c\u3044\u3001\u56f0\u3063\u305f\u3053\u3068\u304c\u767a\u751f\u3057\u305f\u306e\u3067\u3001<br>\u89e3\u6c7a\u3057\u305f\u969b\u306e\u624b\u9806\u3092\u7686\u69d8\u306b\u3082\u5171\u6709\u3057\u3088\u3046\u3068\u601d\u3044\u7b46\u3092\u53d6\u3063\u305f\u6b21\u7b2c\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u3084\u308a\u305f\u304b\u3063\u305f\u3053\u3068\u3000<\/h2>\n\n\n\n<p>\u4eca\u56de\u3084\u3063\u305f\u306e\u306f\u300c\u30e9\u30b8\u30aa\u30dc\u30bf\u30f3\u3067\u304a\u5ba2\u69d8\u306b\u304a\u554f\u3044\u5408\u308f\u305b\u7a2e\u5225\u3092\u9078\u629e\u3057\u3066\u3082\u3089\u3044\u3001\u305d\u308c\u306b\u5fdc\u3058\u3066\u81ea\u52d5\u8fd4\u4fe1\u30e1\u30fc\u30eb\u306e\u4ef6\u540d\u3092\u5909\u66f4\u3059\u308b\u300d\u3068\u3044\u3046\u5b9f\u88c5\u3067\u3059\u3002<br>\u81ea\u52d5\u8fd4\u4fe1\u30e1\u30fc\u30eb\u306e\u4ef6\u540d\u81ea\u4f53\u306fCF7\u306e\u7ba1\u7406\u753b\u9762\u304b\u3089\u8a2d\u5b9a\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001\u5206\u5c90\u3092\u3059\u308b\u305f\u3081\u306b\u306fphp\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u3084\u3063\u305f\u3053\u3068<\/h2>\n\n\n\n<p>\u3053\u3053\u304b\u3089\u306f\u5b9f\u969b\u306e\u30b3\u30fc\u30c9\uff08\u304b\u3089\u304a\u5ba2\u69d8\u306e\u793e\u540d\u3084\u5b9f\u969b\u306e\u9078\u629e\u80a2\u3092\u5909\u3048\u305f\u3082\u306e\uff09\u3092\u898b\u306a\u304c\u3089\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"list clearfix\"&gt;\n  &lt;dl&gt;\n    &lt;dt&gt;&lt;span class=\"required\"&gt;\u5fc5\u9808&lt;\/span&gt;\u304a\u554f\u3044\u5408\u308f\u305b\u7a2e\u5225&lt;\/dt&gt;\n    &lt;dd&gt;\n      &lt;div&gt;\n        &#091;radio contact-type use_label_element \"\u65b0\u898f\u3054\u4f9d\u983c\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b\" \"\u30b5\u30a4\u30c8\u6539\u4fee\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b\" \"\u5354\u696d\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b\" \"\u305d\u306e\u4ed6\u306e\u304a\u554f\u3044\u5408\u308f\u305b\"]\n      &lt;\/div&gt;\n    &lt;\/dd&gt;\n  &lt;\/dl&gt;<\/code><\/pre>\n\n\n\n<p>\u4e0a\u306f4\u629e\u306e\u30e9\u30b8\u30aa\u30dc\u30bf\u30f3\u304c\u3042\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002\u3053\u308c\u3089\u306e\u9078\u629e\u305d\u308c\u305e\u308c\u3067\u4ef6\u540d\u3092\u5909\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<br>\u660e\u5feb\u306b\u7b54\u3048\u3092\u66f8\u304f\u3068\u3001functions.php\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter('wpcf7_mail_components', function ($components, $contact_form, $mail) {\n\n  $submission = WPCF7_Submission::get_instance();\n  if (!$submission) return $components;\n  $data = $submission-&gt;get_posted_data();\n\n  $which = method_exists($mail, 'name') ? $mail-&gt;name() : 'mail';\n\n  $contact_type = $data&#091;'contact-type']&#091;0] ?? '';\n\n  if ($which === 'mail') {\n    if ($contact_type === '\u65b0\u898f\u3054\u4f9d\u983c\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b') {\n      $components&#091;'subject'] = '\u3010\u65b0\u898f\u3011' . $components&#091;'subject'];\n    } elseif ($contact_type === '\u30b5\u30a4\u30c8\u6539\u4fee\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b') {\n      $components&#091;'subject'] = '\u3010\u6539\u4fee\u3011' . $components&#091;'subject'];\n    } elseif ($contact_type === '\u5354\u696d\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b') {\n      $components&#091;'subject'] = '\u3010\u5354\u696d\u3011' . $components&#091;'subject'];\n    } else {\n      $components&#091;'subject'] = '\u3010\u305d\u306e\u4ed6\u3011' . $components&#091;'subject'];\n    }\n  }\n\n  if ($which === 'mail_2') {\n    $components&#091;'subject'] = '\u3010\u682a\u5f0f\u4f1a\u793e\u30cd\u30af\u30b9\u30c8\u30da\u30fc\u30b8\u3011\u304a\u554f\u3044\u5408\u308f\u305b\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059';\n  }\n\n  return $components;\n}, 10, 3);<\/code><\/pre>\n\n\n\n<p>\u5404\u30b3\u30fc\u30c9\u306e\u89e3\u8aac\u3092\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter('wpcf7_mail_components', function ($components, $contact_form, $mail) {\n\n  $submission = WPCF7_Submission::get_instance();\n  if (!$submission) return $components;\n  $data = $submission-&gt;get_posted_data();<\/code><\/pre>\n\n\n\n<p>\u307e\u305a\u3053\u306e\u90e8\u5206\u3067\u6295\u7a3f\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  $which = method_exists($mail, 'name') ? $mail-&gt;name() : 'mail';<\/code><\/pre>\n\n\n\n<p>\u7d9a\u3044\u3066\u3053\u306e\u90e8\u5206\u3067\u306f\u3001\u300c\u30e1\u30fc\u30eb\u300d\u3068\u300c\u30e1\u30fc\u30eb2\u300d\u306e\u3069\u3061\u3089\u306e\u8a2d\u5b9a\u3092\u51e6\u7406\u3057\u3066\u3044\u308b\u304b\u6307\u5b9a\u3057\u307e\u3059\u3002<br>\u300c\u30e1\u30fc\u30eb\u300d\u306f\u5185\u90e8\u3078\u306e\u81ea\u52d5\u8fd4\u4fe1\u3001\u300c\u30e1\u30fc\u30eb2\u300d\u306f\u5165\u529b\u3055\u308c\u305f\u65b9\u3078\u306e\u81ea\u52d5\u8fd4\u4fe1\u306e\u8a2d\u5b9a\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  $contact_type = $data&#091;'contact-type']&#091;0] ?? '';<\/code><\/pre>\n\n\n\n<p>\u3053\u3053\u3067\u30e9\u30b8\u30aa\u30dc\u30bf\u30f3\u306e\u5024\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u30d5\u30a9\u30fc\u30e0\u306ename\u5c5e\u6027\u306b\u5bfe\u5fdc\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  if ($which === 'mail') {\n    if ($contact_type === '\u65b0\u898f\u3054\u4f9d\u983c\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b') {\n      $components&#091;'subject'] = '\u3010\u65b0\u898f\u3011' . $components&#091;'subject'];\n    } elseif ($contact_type === '\u30b5\u30a4\u30c8\u6539\u4fee\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b') {\n      $components&#091;'subject'] = '\u3010\u6539\u4fee\u3011' . $components&#091;'subject'];\n    } elseif ($contact_type === '\u5354\u696d\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b') {\n      $components&#091;'subject'] = '\u3010\u5354\u696d\u3011' . $components&#091;'subject'];\n    } else {\n      $components&#091;'subject'] = '\u3010\u305d\u306e\u4ed6\u3011' . $components&#091;'subject'];\n    }\n  }<\/code><\/pre>\n\n\n\n<p>\u30e9\u30b8\u30aa\u30dc\u30bf\u30f3\u306e\u5024\uff08$contact_type\u306e\u5024\uff09\u3067\u5206\u5c90\u3055\u305b\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  if ($which === 'mail_2') {\n    $components&#091;'subject'] = '\u3010\u682a\u5f0f\u4f1a\u793e\u30cd\u30af\u30b9\u30c8\u30da\u30fc\u30b8\u3011\u304a\u554f\u3044\u5408\u308f\u305b\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059';\n  }<\/code><\/pre>\n\n\n\n<p>\u6700\u5f8c\u306e\u3053\u306e\u90e8\u5206\u306f\u300c\u30e1\u30fc\u30eb2\u300d\u306e\u4ef6\u540d\u3092\u5909\u66f4\u3059\u308b\u306a\u3089\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u3055\u3044\u3054\u306b<\/h2>\n\n\n\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u81ea\u52d5\u8fd4\u4fe1\u30e1\u30fc\u30eb\u306e\u4ef6\u540d\u3092\u5909\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u81ea\u5206\u3067\u8abf\u3079\u3066\u3082\u89e3\u6c7a\u6cd5\u304c\u51fa\u3066\u3053\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u4e0a\u9577\u306e\u529b\u3092\u501f\u308a\u3066\u306a\u3093\u3068\u304b\u30b3\u30fc\u30c9\u3092\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<br>Contact Form 7\u306f\u3088\u304f\u4f7f\u308f\u308c\u308b\u306f\u305a\u306a\u306e\u306b\u30cd\u30c3\u30c8\u4e0a\u306e\u60c5\u5831\u304c\u5c11\u306a\u3044\u30a4\u30e1\u30fc\u30b8\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001<br>\u4eca\u5f8c\u3082\u8a18\u4e8b\u3092\u51fa\u305b\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3001ContactForm7\u3067\u81ea\u52d5\u8fd4\u4fe1\u30e1\u30fc\u30eb\u306e\u4ef6\u540d\u3092\u5206\u5c90\u3055\u305b\u308b\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"author":32,"featured_media":17602,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[10],"tags":[179,172],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/posts\/17516"}],"collection":[{"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17516"}],"version-history":[{"count":3,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/posts\/17516\/revisions"}],"predecessor-version":[{"id":17604,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/posts\/17516\/revisions\/17604"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/media\/17602"}],"wp:attachment":[{"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}