{"id":4338,"date":"2022-06-29T15:57:56","date_gmt":"2022-06-29T14:57:56","guid":{"rendered":"https:\/\/ibex.tech\/wordpress-sites\/?p=4338"},"modified":"2022-07-07T10:40:42","modified_gmt":"2022-07-07T09:40:42","slug":"custom-new-user-registration-fields","status":"publish","type":"post","link":"https:\/\/ibex.tech\/wordpress-sites\/plugins\/buddypress\/members\/custom-new-user-registration-fields","title":{"rendered":"Custom new user registration fields"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">Adding the field to the new user signup page<\/h5>\n\n\n\n<p>BuddyPress options &gt; Components &gt; Extended Profiles = On<\/p>\n\n\n\n<p>Users &gt; Profile Fields<\/p>\n\n\n\n<p>Add the new field and mark it as required for signups<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Validating the value entered<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/******************************************************************\n\/\/******************************************************************\n\/\/********** NEW USER REGISTRATION CHECK FIELDS SUBMITTED **********\n\/\/******************************************************************\n\/\/******************************************************************\nadd_action ('bp_signup_pre_validate', 'myplugin_bp_signup_pre_validate', 20);\nfunction myplugin_bp_signup_pre_validate()\n{\n  global $bp;\n\n  \/\/----- CHECK SIGNUP CODE VALUE ENTERED -----\n  if (!isset($_POST&#91;'field_2']) || $_POST&#91;'field_2'] !== 'ABC')\n  {\n    \/\/Error - Cause signup to fail\n    $bp-&gt;signup-&gt;errors&#91;'field_2'] = 'ERROR - My validation error message';   \/\/Field name must be correct for error message to be shown next to the field\n  }\n  \n}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Hiding &#8220;This field can be see by&#8221; message under fields<\/h5>\n\n\n\n<p>Add this to your themes style.css<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* Hide \"This field can be see by\" on registration and edit profile pages *\/\n.field-visibility-settings-toggle {\ndisplay:none;\n}\n.field-visibility-settings-notoggle {\ndisplay:none;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Adding the field to the new user signup page BuddyPress options &gt; Components &gt; Extended Profiles = On Users &gt; Profile Fields Add the new field and mark it as required for signups Validating the value entered Hiding &#8220;This field can be see by&#8221; message under fields Add this to your themes style.css<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[361],"tags":[],"class_list":["post-4338","post","type-post","status-publish","format-standard","hentry","category-members"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/comments?post=4338"}],"version-history":[{"count":4,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4338\/revisions"}],"predecessor-version":[{"id":4358,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4338\/revisions\/4358"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/media?parent=4338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/categories?post=4338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/tags?post=4338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}