{"id":28984,"date":"2024-11-25T13:57:30","date_gmt":"2024-11-25T05:57:30","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28984\/"},"modified":"2024-11-25T13:57:30","modified_gmt":"2024-11-25T05:57:30","slug":"%e6%80%8e%e4%b9%88%e5%ae%9e%e7%8e%b0%e4%b8%80%e4%b8%aa%e6%97%a0%e9%9c%80%e8%be%93%e5%85%a5%e5%af%86%e7%a0%81%e7%9a%84wordpress%e7%99%bb%e5%bd%95%e8%a1%a8%e5%8d%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28984\/","title":{"rendered":"\u600e\u4e48\u5b9e\u73b0\u4e00\u4e2a\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u7684WordPress\u767b\u5f55\u8868\u5355"},"content":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;<strong>wordpress<\/strong>\u6559\u7a0b\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u7684wordpress\u767b\u5f55\u8868\u5355\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/60a4ad2fa4bcc133.jpg\" class=\"aligncenter\" title=\"\u600e\u4e48\u5b9e\u73b0\u4e00\u4e2a\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u7684WordPress\u767b\u5f55\u8868\u5355\u63d2\u56fe\" alt=\"\u600e\u4e48\u5b9e\u73b0\u4e00\u4e2a\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u7684WordPress\u767b\u5f55\u8868\u5355\u63d2\u56fe\" \/><\/p>\n<p><strong>\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u7684WordPress\u767b\u5f55\u8868\u5355<\/strong><\/p>\n<p>\u5982\u679c\u60f3\u5728WordPress\u4e3b\u9898\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u4e0d\u9700\u8981\u8f93\u5165\u5bc6\u7801\uff0c\u4ec5\u8f93\u5165\u7528\u6237\u540d\u6216\u7535\u5b50\u90ae\u4ef6\u5373\u53ef\u767b\u5f55\u7684\u8868\u5355\uff0c\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\u5b9e\u73b0\u3002<\/p>\n<p>\u590d\u5236\u4ee5\u4e0b\u4ee3\u7801\uff0c\u7c98\u8d34\u5230\u8981\u663e\u793a\u8868\u5355\u7684\u4f4d\u7f6e<\/p>\n<pre><\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 &#8221;&nbsp;class=&#8221;form-control&#8221;&nbsp;required=&#8221;required&#8221;&gt; &nbsp;&nbsp; <\/p>\n<p>\u7136\u540e\uff0c\u5c06\u4e0b\u9762\u4ee3\u7801\u7c98\u8d34\u5230\u4e3b\u9898\u51fd\u6570\u6a21\u677f functions.php\u4e2d\uff1a<\/p>\n<pre>add_action('init',&nbsp;function(){\n\/\/&nbsp;Return&nbsp;if&nbsp;not&nbsp;the&nbsp;login&nbsp;request\nif(&nbsp;!isset(&nbsp;$_POST['action']&nbsp;)&nbsp;||&nbsp;$_POST['action']&nbsp;!==&nbsp;'my_login_action'&nbsp;)\nreturn;\n$result;\n$username&nbsp;=&nbsp;$_POST['userlog'];\nif&nbsp;(&nbsp;!&nbsp;$result&nbsp;)&nbsp;{\n$result&nbsp;=&nbsp;get_user_by(&nbsp;'email',&nbsp;$username&nbsp;);&nbsp;\/\/&nbsp;user&nbsp;email\n}\nif&nbsp;(&nbsp;!&nbsp;$result&nbsp;)&nbsp;{\n$result&nbsp;=&nbsp;get_user_by('login',&nbsp;$username&nbsp;);&nbsp;\/\/&nbsp;user&nbsp;name\n}\n&nbsp;\nif&nbsp;(&nbsp;!is_wp_error($result)&nbsp;){\nwp_clear_auth_cookie();\nwp_set_current_user($result-&amp;gt;ID);\nwp_set_auth_cookie($result-&amp;gt;ID);\nwp_redirect(&nbsp;home_url(&nbsp;'\/'&nbsp;)&nbsp;);\nexit;\n}\ndie();\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u53ea\u9002\u5408\u7279\u5b9a\u573a\u5408\u4f7f\u7528\uff0c\u6b63\u5e38\u60c5\u51b5\u4e0b\u5982\u679c\u522b\u4eba\u77e5\u9053\u4f60\u7684\u767b\u5f55\u4fe1\u606f\uff0c\u4f7f\u7528\u8fd9\u4e2a\u529f\u80fd\u5f88\u80f8\u9669&#8230;<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5b9e\u73b0\u4e00\u4e2a\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u7684WordPress\u767b\u5f55\u8868\u5355\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;wordpress\u6559\u7a0b\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u7684wordpress\u767b\u5f55\u8868\u5355\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01 \u65e0\u9700\u8f93\u5165\u5bc6\u7801\u7684WordPress\u767b\u5f55\u8868\u5355 \u5982\u679c\u60f3\u5728WordPress\u4e3b\u9898\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u4e0d\u9700\u8981\u8f93\u5165\u5bc6\u7801\uff0c\u4ec5\u8f93\u5165\u7528\u6237\u540d\u6216\u7535\u5b50\u90ae\u4ef6\u5373\u53ef\u767b\u5f55\u7684\u8868\u5355\uff0c\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\u5b9e\u73b0\u3002 \u590d\u5236\u4ee5\u4e0b\u4ee3\u7801\uff0c\u7c98\u8d34\u5230\u8981\u663e\u793a\u8868\u5355\u7684\u4f4d\u7f6e \u767b\u5f55\u540e\u590d\u5236 &#8221;&nbsp;class=&#8221;form-control&#8221;&nbsp;required=&#8221;required&#8221;&gt; &nbsp;&nbsp; \u7136\u540e\uff0c\u5c06\u4e0b\u9762\u4ee3\u7801\u7c98\u8d34\u5230\u4e3b\u9898\u51fd\u6570\u6a21\u677f functions.php\u4e2d\uff1a add_action(&#8216;init&#8217;,&nbsp;function(){ \/\/&nbsp;Return&nbsp;if&nbsp;not&nbsp;the&nbsp;login&nbsp;request if(&nbsp;!isset(&nbsp;$_POST[&#8216;action&#8217;]&nbsp;)&nbsp;||&nbsp;$_POST[&#8216;action&#8217;]&nbsp;!==&nbsp;&#8216;my_login_action&#8217;&nbsp;) return; $result; $username&nbsp;=&nbsp;$_POST[&#8216;userlog&#8217;]; if&nbsp;(&nbsp;!&nbsp;$result&nbsp;)&nbsp;{ $result&nbsp;=&nbsp;get_user_by(&nbsp;&#8217;email&#8217;,&nbsp;$username&nbsp;);&nbsp;\/\/&nbsp;user&nbsp;email } if&nbsp;(&nbsp;!&nbsp;$result&nbsp;)&nbsp;{ $result&nbsp;=&nbsp;get_user_by(&#8216;login&#8217;,&nbsp;$username&nbsp;);&nbsp;\/\/&nbsp;user&nbsp;name } &nbsp; if&nbsp;(&nbsp;!is_wp_error($result)&nbsp;){ wp_clear_auth_cookie(); wp_set_current_user($result-&amp;gt;ID); wp_set_auth_cookie($result-&amp;gt;ID); wp_redirect(&nbsp;home_url(&nbsp;&#8216;\/&#8217;&nbsp;)&nbsp;); exit; } die(); }); \u767b\u5f55\u540e\u590d\u5236 \u53ea\u9002\u5408\u7279\u5b9a\u573a\u5408\u4f7f\u7528\uff0c\u6b63\u5e38\u60c5\u51b5\u4e0b\u5982\u679c\u522b\u4eba\u77e5\u9053\u4f60\u7684\u767b\u5f55\u4fe1\u606f\uff0c\u4f7f\u7528\u8fd9\u4e2a\u529f\u80fd\u5f88\u80f8\u9669&#8230; \u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5b9e\u73b0\u4e00\u4e2a\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u7684WordPress\u767b\u5f55\u8868\u5355\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-28984","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28984","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=28984"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28984\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}