{"id":11217,"date":"2023-04-17T18:16:47","date_gmt":"2023-04-17T09:16:47","guid":{"rendered":"https:\/\/hanami-web.tokyo.jp\/blog\/?p=11217"},"modified":"2024-06-16T14:08:37","modified_gmt":"2024-06-16T05:08:37","slug":"add-first-and-last-name-fields-to-the-user-registration-form","status":"publish","type":"post","link":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/microjobs\/add-first-and-last-name-fields-to-the-user-registration-form\/","title":{"rendered":"Creating a matching site using WordPress [HivePress] Adding first and last name fields to the user registration form"},"content":{"rendered":"<div class=\"sc\"><a href=\"https:\/\/hanami-web.tokyo.jp\/blog\/en\/how-to-hivepress-setting\/\" title=\"HivePress Explanation Table of Contents\">\r\n\t<p class=\"sc-txt01\">Our company also built a matching website using HivePress.<\/p>\r\n\t<p class=\"sc-txt01\">How to create a matching website using WordPress<\/p>\r\n\t<p class=\"sc-txt02\">HivePress Explanation Table of Contents \u2192<\/p>\r\n<\/a><\/div>\n\n\n<div class=\"sc af\"><a href=\"https:\/\/hivepress.io\/?ref=hv\" title=\"HivePress Official Website\" target=\"_blank\">\r\n\t<p class=\"sc-txt02\">HivePress official website \u2192<\/p>\r\n<\/a><\/div>\n\n\n\n<p>We will explain the code introduced in the HivePress code recipe.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">table of contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #000000;color:#000000\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #000000;color:#000000\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/hanami-web.tokyo.jp\/blog\/en\/microjobs\/add-first-and-last-name-fields-to-the-user-registration-form\/#%e3%82%b3%e3%83%bc%e3%83%89%e3%82%b9%e3%83%8b%e3%83%9a%e3%83%83%e3%83%88\" >Code snippet<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/hanami-web.tokyo.jp\/blog\/en\/microjobs\/add-first-and-last-name-fields-to-the-user-registration-form\/#%e5%ae%9f%e8%a3%85%e7%b5%90%e6%9e%9c\" >Implementation results<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/hanami-web.tokyo.jp\/blog\/en\/microjobs\/add-first-and-last-name-fields-to-the-user-registration-form\/#functionphp%e3%81%b8%e8%bf%bd%e5%8a%a0\" >Add to function.php<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%e3%82%b3%e3%83%bc%e3%83%89%e3%82%b9%e3%83%8b%e3%83%9a%e3%83%83%e3%83%88\"><\/span>Code snippet<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Add first and last name fields to user registration form<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[ &#039;required&#039; =&gt; true, &#039;_order&#039; =&gt; 1, ], &#039;last_name&#039; =&gt; [ &#039;required&#039; =&gt; true, &#039;_order&#039; =&gt; 2, ], ] ); return $form; }, 100 ); add_action( &#039;hivepress\/v1\/models\/user\/register&#039;, function( $user_id, $values ) { if ( isset( $values[&#039;first_name&#039;] ) ) { update_user_meta( $user_id, &#039;first_name&#039;, $values[&#039;first_name&#039;] ); } if ( isset( $values[&#039;last_name&#039;] ) ) { update_user_meta( $user_id, &#039;last_name&#039;, $values[&#039;last_name&#039;] ); } }, 10, 2 );\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%e5%ae%9f%e8%a3%85%e7%b5%90%e6%9e%9c\"><\/span>Implementation results<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>After adding the code, a first and last name field was added to the user registration form.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"435\" src=\"https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/image-52-1024x435.png\" alt=\"\" class=\"wp-image-11297\" srcset=\"https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/image-52-1024x435.png 1024w, https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/image-52-300x127.png 300w, https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/image-52-768x326.png 768w, https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/image-52.png 1183w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"functionphp%e3%81%b8%e8%bf%bd%e5%8a%a0\"><\/span>Add to function.php<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The code is added to function.php.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a child theme and add it to function.php<\/li>\n\n\n\n<li>Added using the code snippets plugin<\/li>\n<\/ul>\n\n\n\n<p>Please edit function.php in one of two ways.<\/p>\n\n\n\n<p><a href=\"https:\/\/hanami-web.tokyo.jp\/blog\/en\/member\/php-customize\/\" title=\"\"><span style=\"text-decoration: underline;\">This blog post explains the prerequisites you need to know before editing function.php!<\/span><\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>HivePress\u306e\u30b3\u30fc\u30c9\u30ec\u30b7\u30d4\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u30b3\u30fc\u30c9\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002 \u30b3\u30fc\u30c9\u30b9\u30cb\u30da\u30c3\u30c8 \u30e6\u30fc\u30b6\u30fc\u767b\u9332\u30d5\u30a9\u30fc\u30e0\u306b\u59d3\u3068\u540d\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8ffd\u52a0 \u5b9f\u88c5\u7d50\u679c \u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u305f\u3068\u3053\u308d\u3001\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u30d5\u30a9\u30fc\u30e0\u306b\u59d3\u540d\u6b04\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f fu [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":11294,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","_uag_custom_page_level_css":"","footnotes":""},"categories":[1456],"tags":[1501],"class_list":["post-11217","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microjobs","tag-hivepress"],"blocksy_meta":[],"aioseo_notices":[],"uagb_featured_image_src":{"full":["https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/HivePress-2-2.png",720,540,false],"thumbnail":["https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/HivePress-2-2-150x150.png",150,150,true],"medium":["https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/HivePress-2-2-300x225.png",300,225,true],"medium_large":["https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/HivePress-2-2.png",720,540,false],"large":["https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/HivePress-2-2.png",720,540,false],"1536x1536":["https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/HivePress-2-2.png",720,540,false],"2048x2048":["https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/HivePress-2-2.png",720,540,false],"trp-custom-language-flag":["https:\/\/hanami-web.tokyo.jp\/blog\/wp-content\/uploads\/2023\/03\/HivePress-2-2.png",16,12,false]},"uagb_author_info":{"display_name":"\u682a\u5f0f\u4f1a\u793eHanamiWEB \u4ee3\u8868\u53d6\u7de0\u5f79 \u677e\u6d66\u307f\u3055","author_link":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/author\/hanami\/"},"uagb_comment_info":0,"uagb_excerpt":"HivePress\u306e\u30b3\u30fc\u30c9\u30ec\u30b7\u30d4\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u30b3\u30fc\u30c9\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002 \u30b3\u30fc\u30c9\u30b9\u30cb\u30da\u30c3\u30c8 \u30e6\u30fc\u30b6\u30fc\u767b\u9332\u30d5\u30a9\u30fc\u30e0\u306b&hellip;","brizy_media":[],"_links":{"self":[{"href":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/wp-json\/wp\/v2\/posts\/11217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/wp-json\/wp\/v2\/comments?post=11217"}],"version-history":[{"count":0,"href":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/wp-json\/wp\/v2\/posts\/11217\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/wp-json\/wp\/v2\/media\/11294"}],"wp:attachment":[{"href":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/wp-json\/wp\/v2\/media?parent=11217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/wp-json\/wp\/v2\/categories?post=11217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hanami-web.tokyo.jp\/blog\/en\/wp-json\/wp\/v2\/tags?post=11217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}