{"id":2513,"date":"2019-12-28T09:31:37","date_gmt":"2019-12-28T09:31:37","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2513"},"modified":"2022-06-29T16:19:54","modified_gmt":"2022-06-29T15:19:54","slug":"user-registration","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/wordpress\/users\/user-registration","title":{"rendered":"User Registration"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">WordPress user registration<\/h5>\n\n\n\n<p>WordPress has built in user registration functionality, however it is username or email address based and not brilliant visually.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Enable user registration via wordpress<\/h5>\n\n\n\n<p>Settings &gt; General &gt; Membership &gt; Anyone can register<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">User register<\/h5>\n\n\n\n<p>https:\/\/yoursite.com\/wp-admin<\/p>\n\n\n\n<p>https:\/\/yoursite.com\/wp-login.php?action=register<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Adding a custom field to new user registration<\/h4>\n\n\n\n<p> Note &#8211; this will not work with BuddyPress, as BuddyPress overrides the default WP registration<\/p>\n\n\n\n<p><em>This code not yet tested but should just work:<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/******************************************************************\n\/\/******************************************************************\n\/\/********** NEW USER REGISTRATION ADD CUSTOM FORM FIELDS **********\n\/\/******************************************************************\n\/\/******************************************************************\nfunction myplugin_register_form()\n{\n  \/\/die(\"WORKED\");\n    \/\/Handle form resubmission - get any fields previously submitted\n    $signup_code = ( isset( $_POST&#91;'signup_code'] ) ) ? $_POST&#91;'signup_code'] : '';\n    ?>\n \n    &lt;p>\n        &lt;label for=\"signup_code\">Signup Code&lt;br \/>\n        &lt;input type=\"text\" name=\"signup_code\" id=\"signup_code\" class=\"input\" value=\"&lt;?php echo esc_attr( stripslashes( $signup_code ) ); ?>\" size=\"25\" \/>&lt;\/label>\n    &lt;\/p>\n \n    &lt;?php\n}\nadd_action('register_form', 'myplugin_register_form');\n\n\n\/\/******************************************************************\n\/\/******************************************************************\n\/\/********** NEW USER REGISTRATION CHECK FIELDS SUBMITTED **********\n\/\/******************************************************************\n\/\/******************************************************************\nadd_filter( 'registration_errors', 'myplugin_registration_errors', 10, 3 );\nfunction myplugin_registration_errors ($errors, $sanitized_user_login, $user_email)\n{\n \n  if (!isset($_POST&#91;'signup_code']) || $_POST&#91;'signup_code'] !== 'ABC')\n  {\n    \/\/Cause signup to fail\n    $errors->add( 'My_custom_error', '&lt;strong>ERROR&lt;\/strong>: Invalid Signup Code.' );\n  }\n\n  return $errors;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>WordPress user registration WordPress has built in user registration functionality, however it is username or email address based and not brilliant visually. Enable user registration via wordpress Settings &gt; General &gt; Membership &gt; Anyone can register User register https:\/\/yoursite.com\/wp-admin https:\/\/yoursite.com\/wp-login.php?action=register Adding a custom field to new user registration Note &#8211; this will not work with [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[168],"tags":[],"class_list":["post-2513","post","type-post","status-publish","format-standard","hentry","category-users"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2513"}],"version-history":[{"count":5,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2513\/revisions"}],"predecessor-version":[{"id":4325,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2513\/revisions\/4325"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}