{"id":6721,"date":"2024-10-24T11:07:58","date_gmt":"2024-10-24T02:07:58","guid":{"rendered":"https:\/\/code-plus.jp\/gp\/?p=6721"},"modified":"2026-10-28T20:13:21","modified_gmt":"2026-10-28T11:13:21","slug":"post-6721","status":"publish","type":"post","link":"https:\/\/code-plus.jp\/gp\/post-6721\/","title":{"rendered":"WordPress\u306e\u30e1\u30fc\u30eb\u30bf\u30b0\u30fb\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u307e\u3068\u3081\u3066\u7ba1\u7406\u3057\u3084\u3059\u3044\u5f62\u306b\u6574\u7406\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u30e1\u30fc\u30eb\u30d5\u30a9\u30fc\u30e0\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30bf\u30b0\u3084\u3001WordPress\u306e\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u52b9\u7387\u7684\u306b\u7ba1\u7406\u3059\u308b\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002\u8907\u6570\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u4f7f\u7528\u3055\u308c\u308b\u5171\u901a\u306e\u60c5\u5831\u3092\u4e00\u5143\u7ba1\u7406\u3059\u308b\u3053\u3068\u3067\u3001\u4fdd\u5b88\u6027\u306e\u5411\u4e0a\u3068\u30b3\u30fc\u30c9\u306e\u7c21\u6f54\u5316\u3092\u5b9f\u73fe\u3057\u307e\u3059\u3002<\/p>\n<h2>1. \u30e1\u30fc\u30eb\u30bf\u30b0\u306e\u6574\u7406<\/h2>\n<h3>MW WP Form \u306e\u30e1\u30fc\u30eb\u30bf\u30b0<\/h3>\n<pre><code class=\"language-php\">\/*\u300eMW WP Form\u300f{\u30e1\u30fc\u30eb\u30bf\u30b0} \u8a2d\u5b9a --------------------------------------*\/\nfunction add_sender_info($value, $key, $insert_contact_data_id) {\n    global $my_recipients, $my_recipients2, $my_recipients3, $my_recipients4;\n    \n    \/\/ \u30b5\u30fc\u30d0\u30fc\u60c5\u5831\u95a2\u9023\n    $server_info = array(\n        &#39;user_agent&#39; =&gt; $_SERVER[&quot;HTTP_USER_AGENT&quot;],\n        &#39;ip&#39; =&gt; $_SERVER[&quot;REMOTE_ADDR&quot;],\n        &#39;host&#39; =&gt; gethostbyaddr($_SERVER[&quot;REMOTE_ADDR&quot;])\n    );\n    if (isset($server_info[$key])) {\n        return $server_info[$key];\n    }\n    \n    \/\/ \u65e5\u6642\u60c5\u5831\n    if ($key === &#39;send_datetime&#39;) {\n        return wp_date(&quot;Y\u5e74n\u6708j\u65e5 H:i:s&quot;, null, new DateTimeZone(&#39;Asia\/Tokyo&#39;));\n    }\n    \n    \/\/ \u6295\u7a3f\u60c5\u5831\u95a2\u9023\n    $post_info = array(\n        &#39;title&#39; =&gt; get_the_title(),\n        &#39;maintitle&#39; =&gt; get_post_meta(get_the_ID(), &#39;maintitle&#39;, true),\n        &#39;subtitle&#39; =&gt; get_post_meta(get_the_ID(), &#39;subtitle&#39;, true)\n    );\n    if (isset($post_info[$key])) {\n        return $post_info[$key];\n    }\n    \n    \/\/ \u30e1\u30fc\u30eb\u9001\u4fe1\u5148\u95a2\u9023\n    $recipients_map = array(\n        &#39;my_recipients&#39; =&gt; $my_recipients,\n        &#39;my_recipients2&#39; =&gt; $my_recipients2,\n        &#39;my_recipients3&#39; =&gt; $my_recipients3,\n        &#39;my_recipients4&#39; =&gt; $my_recipients4\n    );\n    if (isset($recipients_map[$key])) {\n        return $recipients_map[$key];\n    }\n    \n    return $value;\n}\nadd_filter(&#39;mwform_custom_mail_tag&#39;, &#39;add_sender_info&#39;, 10, 3);\n<\/code><\/pre>\n<h3>Contact Form 7 \u306e\u30e1\u30fc\u30eb\u30bf\u30b0<\/h3>\n<pre><code class=\"language-php\">\/*\u300eContact Form 7\u300f[_\u30e1\u30fc\u30eb\u30bf\u30b0] \u8a2d\u5b9a ----------------------------------*\/\nfunction add_wpcf7_custom_mail_tags($output, $name) {\n    global $my_recipients, $my_recipients2;\n    \n    \/\/ \u63a5\u982d\u8f9e&quot;_&quot;\u3092\u524a\u9664\u3057\u3066\u30ad\u30fc\u540d\u3092\u53d6\u5f97\n    $key = ltrim($name, &#39;_&#39;);\n    \n    \/\/ \u6295\u7a3f\u60c5\u5831\u95a2\u9023\n    $post_info = array(\n        &#39;title&#39; =&gt; get_the_title(),\n        &#39;maintitle&#39; =&gt; get_post_meta(get_the_ID(), &#39;maintitle&#39;, true),\n        &#39;subtitle&#39; =&gt; get_post_meta(get_the_ID(), &#39;subtitle&#39;, true)\n    );\n    if (isset($post_info[$key])) {\n        return $post_info[$key];\n    }\n    \n    \/\/ \u30e1\u30fc\u30eb\u9001\u4fe1\u5148\u95a2\u9023\n    $recipients_map = array(\n        &#39;my_recipients&#39; =&gt; $my_recipients,\n        &#39;my_recipients2&#39; =&gt; $my_recipients2\n    );\n    if (isset($recipients_map[$key])) {\n        return $recipients_map[$key];\n    }\n    \n    return $output;\n}\nadd_filter(&#39;wpcf7_special_mail_tags&#39;, &#39;add_wpcf7_custom_mail_tags&#39;, 10, 2);\n<\/code><\/pre>\n<h2>\u30b3\u30fc\u30c9\u306e\u89e3\u8aac<\/h2>\n<h3>1. \u60c5\u5831\u306e\u30b0\u30eb\u30fc\u30d7\u5316<\/h3>\n<ul style=\"list-style-type:bullet;\">\n<li>\u95a2\u9023\u3059\u308b\u60c5\u5831\u3092\u914d\u5217\u3067\u30b0\u30eb\u30fc\u30d7\u5316<\/li>\n<li>\u30b5\u30fc\u30d0\u30fc\u60c5\u5831\u3001\u6295\u7a3f\u60c5\u5831\u3001\u30e1\u30fc\u30eb\u9001\u4fe1\u5148\u306a\u3069\u3092\u30ab\u30c6\u30b4\u30ea\u5206\u3051<\/li>\n<li>\u65b0\u3057\u3044\u9805\u76ee\u306e\u8ffd\u52a0\u304c\u5bb9\u6613\u306a\u69cb\u9020<\/li>\n<\/ul>\n<h3>2. \u6761\u4ef6\u5206\u5c90\u306e\u52b9\u7387\u5316<\/h3>\n<ul style=\"list-style-type:bullet;\">\n<li>\u914d\u5217\u3092\u4f7f\u7528\u3057\u3066\u6761\u4ef6\u5206\u5c90\u3092\u7c21\u7565\u5316<\/li>\n<li>\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u306e\u5411\u4e0a<\/li>\n<li>\u30b3\u30fc\u30c9\u306e\u91cd\u8907\u3092\u9632\u6b62<\/li>\n<\/ul>\n<h3>3. \u30a8\u30e9\u30fc\u51e6\u7406<\/h3>\n<ul style=\"list-style-type:bullet;\">\n<li>\u5b58\u5728\u3057\u306a\u3044\u30ad\u30fc\u3078\u306e\u5b89\u5168\u306a\u30a2\u30af\u30bb\u30b9<\/li>\n<li>\u672a\u5b9a\u7fa9\u306e\u5024\u306b\u5bfe\u3059\u308b\u30d5\u30a9\u30fc\u30eb\u30d0\u30c3\u30af<\/li>\n<li>\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u3092\u78ba\u4fdd<\/li>\n<\/ul>\n<h3>4. \u30d7\u30e9\u30b0\u30a4\u30f3\u56fa\u6709\u306e\u51e6\u7406<\/h3>\n<ul style=\"list-style-type:bullet;\">\n<li>MW WP Form: <code>{\u30bf\u30b0\u540d}<\/code> \u5f62\u5f0f\u3067\u30a2\u30af\u30bb\u30b9<\/li>\n<li>Contact Form 7: <code>[_\u30bf\u30b0\u540d]<\/code> \u5f62\u5f0f\u3067\u30a2\u30af\u30bb\u30b9<\/li>\n<li>\u30d7\u30e9\u30b0\u30a4\u30f3\u3054\u3068\u306e\u4ed5\u69d8\u306b\u5bfe\u5fdc<\/li>\n<\/ul>\n<h2>\u4f7f\u7528\u4f8b<\/h2>\n<h3>MW WP Form \u3067\u306e\u4f7f\u7528<\/h3>\n<pre><code>{title} : \u8a18\u4e8b\u30bf\u30a4\u30c8\u30eb\n{my_recipients} : \u9001\u4fe1\u5148\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\n{send_datetime} : \u9001\u4fe1\u65e5\u6642\n<\/code><\/pre>\n<h3>Contact Form 7 \u3067\u306e\u4f7f\u7528<\/h3>\n<pre><code>[_title] : \u8a18\u4e8b\u30bf\u30a4\u30c8\u30eb\n[_my_recipients] : \u9001\u4fe1\u5148\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\n<\/code><\/pre>\n<h2>\u30e1\u30ea\u30c3\u30c8<\/h2>\n<ol style=\"list-style-type:decimal;\">\n<li><p><strong>\u4e00\u5143\u7ba1\u7406<\/strong><\/p>\n<ul style=\"list-style-type:bullet;\">\n<li>\u5171\u901a\u60c5\u5831\u30921\u7b87\u6240\u3067\u7ba1\u7406<\/li>\n<li>\u5024\u306e\u66f4\u65b0\u304c\u5bb9\u6613<\/li>\n<li>\u6574\u5408\u6027\u306e\u7dad\u6301<\/li>\n<\/ul>\n<\/li>\n<li><p><strong>\u4fdd\u5b88\u6027<\/strong><\/p>\n<ul style=\"list-style-type:bullet;\">\n<li>\u30b3\u30fc\u30c9\u306e\u898b\u901a\u3057\u304c\u826f\u597d<\/li>\n<li>\u30c7\u30d0\u30c3\u30b0\u304c\u5bb9\u6613<\/li>\n<li>\u62e1\u5f35\u304c\u7c21\u5358<\/li>\n<\/ul>\n<\/li>\n<li><p><strong>\u52b9\u7387\u6027<\/strong><\/p>\n<ul style=\"list-style-type:bullet;\">\n<li>\u91cd\u8907\u30b3\u30fc\u30c9\u306e\u524a\u6e1b<\/li>\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u5411\u4e0a<\/li>\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u306e\u6700\u9069\u5316<\/li>\n<\/ul>\n<\/li>\n<li><p><strong>\u62e1\u5f35\u6027<\/strong><\/p>\n<ul style=\"list-style-type:bullet;\">\n<li>\u65b0\u3057\u3044\u30bf\u30b0\u306e\u8ffd\u52a0\u304c\u5bb9\u6613<\/li>\n<li>\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u8ffd\u52a0\u5bfe\u5fdc\u304c\u5bb9\u6613<\/li>\n<li>\u69cb\u9020\u5316\u3055\u308c\u305f\u30b3\u30fc\u30c9<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h2>\u6ce8\u610f\u70b9<\/h2>\n<ul style=\"list-style-type:bullet;\">\n<li>\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306b\u3088\u308b\u5f71\u97ff\u3092\u8003\u616e<\/li>\n<li>\u30bf\u30b0\u540d\u306e\u91cd\u8907\u306b\u6ce8\u610f<\/li>\n<li>\u9069\u5207\u306a\u30a8\u30e9\u30fc\u51e6\u7406\u306e\u5b9f\u88c5<\/li>\n<\/ul>\n<p>\u3053\u306e\u3088\u3046\u306a\u6574\u7406\u306b\u3088\u308a\u3001\u8907\u6570\u306e\u30d5\u30a9\u30fc\u30e0\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3059\u308b\u30b5\u30a4\u30c8\u3067\u3082\u3001\u4e00\u8cab\u6027\u306e\u3042\u308b\u52b9\u7387\u7684\u306a\u7ba1\u7406\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u30e1\u30fc\u30eb\u30d5\u30a9\u30fc\u30e0\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30bf\u30b0\u3084\u3001WordPress\u306e\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u52b9\u7387\u7684\u306b\u7ba1\u7406\u3059\u308b\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002\u8907\u6570\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u4f7f\u7528\u3055\u308c\u308b\u5171\u901a\u306e\u60c5\u5831\u3092\u4e00\u5143\u7ba1\u7406\u3059\u308b\u3053\u3068\u3067\u3001\u4fdd\u5b88\u6027\u306e\u5411\u4e0a\u3068\u30b3\u30fc\u30c9\u306e\u7c21\u6f54\u5316\u3092\u5b9f\u73fe\u3057\u307e\u3059\u3002 1. \u30e1\u30fc[...]","protected":false},"author":1,"featured_media":6730,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[],"group":[],"pg":[],"class_list":["post-6721","post","type-post","status-publish","format-standard","has-post-thumbnail","category-php-wordpress"],"acf":[],"_links":{"self":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/6721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/comments?post=6721"}],"version-history":[{"count":1,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/6721\/revisions"}],"predecessor-version":[{"id":15803,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/6721\/revisions\/15803"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/media\/6730"}],"wp:attachment":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/media?parent=6721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/categories?post=6721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/tags?post=6721"},{"taxonomy":"group","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/group?post=6721"},{"taxonomy":"pg","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/pg?post=6721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}