{"id":2886,"date":"2019-02-23T18:39:38","date_gmt":"2019-02-23T17:39:38","guid":{"rendered":"https:\/\/www.sviluppomania.com\/it\/?p=2886"},"modified":"2022-06-26T18:51:30","modified_gmt":"2022-06-26T16:51:30","slug":"come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress","status":"publish","type":"post","link":"https:\/\/www.sviluppomania.com\/en\/how-to-add-custom-fields-to-the-registration-form-in-wordpress\/","title":{"rendered":"How to add custom fields to the registration form in WordPress?"},"content":{"rendered":"<p>&nbsp;<\/p>\r\n<p>If we want to learn more about subscribers of our website or if we need to have additional data for example: a marketing campaign, it may be useful to <strong>add a custom field or more fields to the WordPress registration form<\/strong>.<\/p>\r\n<p>&nbsp;<\/p>\r\n<h3>Such as?<\/h3>\r\n<p>In my case I added some essential data for my website in the registration form and are:\u00a0 <strong>First Name, Last Name, Nickname and Consent to the Privacy Policy<\/strong> (Mandatory for all sites), obviously in your form you can insert many other mandatory fields according to the your needs but to make you the most understandable thing in this guide, I will focus only on the fields on the four fields that I added in my form. If you are involved in handling some code you can use or modify this code according to your needs, as I said before.<\/p>\r\n<p>The code that you will find in this guide must be inserted in a file that you will call for ex. <strong>custom_form.php<\/strong> and the same file in a directory that you must create, is similar to that of the <strong>plugins<\/strong> in Wp-Content and that will be called<strong> mu-plugins<\/strong> (<a href=\"https:\/\/codex.wordpress.org\/Must_Use_Plugins\">Must Use Plugins<\/a>), soon there will be a guide on the mu -plugins.<\/p>\r\n<p>&nbsp;<\/p>\r\n<h3>1. How can I add a new item to the form?<\/h3>\r\n<p>&nbsp;<\/p>\r\n<p>We need to add a new element to the registration form as the very first thing to do and to get our result we need to use the <a href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\/register_form\">register_form<\/a> Hook, then we create new input fields for our additional data.<\/p>\r\n\r\n<pre class=\"wp-block-syntaxhighlighter-code\">&lt;?php add_action('register_form','myplugin_register_form');\r\n \r\n    function myplugin_register_form (){\r\n        $first_name = ( isset( $_POST['first_name'] ) ) ? $_POST['first_name']: ''; \/\/ Saving the First Name field\r\n\t\t$last_name = ( isset( $_POST['last_name'] ) ) ? $_POST['last_name']: ''; \/\/ Saving the Last Name field\r\n\t\t$nickname = ( isset( $_POST['nickname'] ) ) ? $_POST['nickname']: ''; \/\/ Saving the Nickname field\r\n        $privacyPolicy = ( isset( $_POST['privacy_policy'] ) ) ? $_POST['privacy_policy']: '0'; \/\/ Saving the Privacy Policy field\r\n        \r\n\t\tif (get_locale() == 'it_IT') {\r\n        ?&gt;\r\n        &lt;p&gt;\r\n            &lt;label for=\"first_name\"&gt;&lt;?php _e('Nome','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"first_name\" id=\"first_name\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($first_name)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;p&gt;\r\n            &lt;label for=\"last_name\"&gt;&lt;?php _e('Cognome','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"last_name\" id=\"last_name\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($last_name)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;p&gt;\r\n            &lt;label for=\"nickname\"&gt;&lt;?php _e('Nickname','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"nickname\" id=\"nickname\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($nickname)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;br&gt;\r\n\t\t&lt;p&gt;\r\n\t\t&lt;input type=\"checkbox\" name=\"privacy_policy\" value=\"1\" aria-invalid=\"false\" &lt;?php if ($privacyPolicy == \"1\") { echo \"checked\"; } else { echo \"\"; } ?&gt;&gt;&lt;\/span&gt;&lt;\/span&gt;&lt;\/span&gt; ACCETTO I &lt;a href=\"https:\/\/www.sviluppomania.com\/it\/termsconditions\/\"&gt;TERMINI E CONDIZIONI D'USO&lt;\/a&gt; E L'&lt;a href=\"https:\/\/www.sviluppomania.com\/it\/privacy\/\"&gt;INFORMATIVA SULLA PRIVACY&lt;\/a&gt;.&lt;\/p&gt;\r\n\t\t&lt;br&gt;&lt;br&gt;\r\n\t\t&lt;\/p&gt;\r\n\t\t\r\n\t\t&lt;?php } else { ?&gt;\r\n\t\t\r\n\t\t&lt;p&gt;\r\n            &lt;label for=\"first_name\"&gt;&lt;?php _e('First Name','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"first_name\" id=\"first_name\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($first_name)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;p&gt;\r\n            &lt;label for=\"last_name\"&gt;&lt;?php _e('Last Name','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"surname\" id=\"last_name\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($last_name)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;p&gt;\r\n            &lt;label for=\"nickname\"&gt;&lt;?php _e('Nickname','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"nickname\" id=\"nickname\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($nickname)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;br&gt;\r\n\t\t&lt;p&gt;\r\n\t\t&lt;input type=\"checkbox\" name=\"privacy_policy\" value=\"1\" aria-invalid=\"false\" &lt;?php if ($privacyPolicy == \"1\") { echo \"checked\"; } else { echo \"\"; } ?&gt;&gt;&lt;\/span&gt;&lt;\/span&gt;&lt;\/span&gt; I ACCEPT THE &lt;a href=\"https:\/\/www.sviluppomania.com\/en\/termsconditions\/\"&gt;TERMS AND CONDITIONS OF USE&lt;\/a&gt; AND THE &lt;a href=\"https:\/\/www.sviluppomania.com\/en\/privacy\/\"&gt;PRIVACY POLICY&lt;\/a&gt;.&lt;\/p&gt;\r\n\t\t&lt;br&gt;&lt;br&gt;\r\n\t\t&lt;\/p&gt;\r\n\t\t\r\n\t\t&lt;?php }\r\n    }<\/pre>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p>All&#8217;interno del codice troverete anche una suddivisione per multilingua con il Plugin Qtranslate-X, il codice in questione \u00e8:<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<pre class=\"wp-block-syntaxhighlighter-code\">if (get_locale() == 'it_IT') {\r\n\r\n\r\n&lt;?php } else { ?&gt;\r\n\r\n\r\n&lt;?php }<br \/><br \/>If you do not need this multi-language code for the aforementioned Plugin, just delete all the code that includes <strong>&lt;? Php} else {?&gt;<\/strong> Up to <strong>&lt;? Php }<\/strong> and also delete <strong>if (get_locale () == 'it_IT') { <\/strong>so only the code for the Italian language will remain, you will find other pieces of code later on but if you follow our advice you will only have one in Italian.<\/pre>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<h3 class=\"wp-block-heading\"><br \/>2. How to validate the data entered?<\/h3>\r\n<p>It is not only necessary to enter data but also to check the validation (in our case <strong>First Name, Last Name, Nickname and PrivacyPolicy<\/strong>), we should use the Hook <a href=\"http:\/\/codex.wordpress.org\/Plugin_API\/Filter_Reference\/registration_errors\">registration_errors<\/a>, in this way control the field so that it is not empty as it must be mandatory. Depending on your needs, you can perform any checks on the data entered.<\/p>\r\n<p>&nbsp;<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<pre class=\"wp-block-syntaxhighlighter-code\">add_filter('registration_errors', 'myplugin_registration_errors', 10, 3);\r\n    function myplugin_registration_errors ($errors, $sanitized_user_login, $user_email) {\r\n \r\n        if ( empty( $_POST['first_name'] ) ) \/\/ The First Name field is mandatory and can not be empty\r\n\t\t{\r\n\t\t\tif (get_locale() == 'it_IT') {\r\n\t\t\t\t$errors-&gt;add( 'first_name_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Devi inserire il tuo Nome','registrazione-utenti') );\r\n\t\t\t} else {\r\n\t\t\t\t$errors-&gt;add( 'first_name_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Please, type your first name ','registrazione-utenti') );\r\n\t\t\t}\r\n\t\t}\r\n\t\t\t\r\n\t\tif ( empty( $_POST['last_name'] ) ) \/\/ The Last Name field is mandatory and can not be empty\r\n\t\t{\r\n\t\t\tif (get_locale() == 'it_IT') {\r\n\t\t\t\t$errors-&gt;add( 'last_name_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Devi inserire il tuo Cognome','registrazione-utenti') );\t\r\n\t\t\t} else {\r\n\t\t\t\t$errors-&gt;add( 'last_name_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Please, type your last name','registrazione-utenti') );\t\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t\t\tif ( empty( $_POST['nickname'] ) ) \/\/ The Nickname field is mandatory and can not be empty\r\n\t\t{\r\n\t\t\tif (get_locale() == 'it_IT') {\r\n\t\t\t\t$errors-&gt;add( 'nickname_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Devi inserire il tuo Nickname','registrazione-utenti') );\t\r\n\t\t\t} else {\r\n\t\t\t\t$errors-&gt;add( 'nickname_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Please, type your nickname','registrazione-utenti') );\t\r\n\t\t\t}\r\n\t\t}\r\n\r\n        if ( empty( $_POST['privacy_policy'] ) || $_POST['privacy_policy'] != \"1\") \/\/ Consent to the Privacy Policy is mandatory\r\n\t\t{\r\n\t\t\tif (get_locale() == 'it_IT') {\r\n\t\t\t\t$errors-&gt;add( 'privacy_policy_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Devi accettare l\\'informativa sulla privacy','registrazione-utenti') );\r\n\t\t\t} else {\r\n\t\t\t\t$errors-&gt;add( 'privacy_policy_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Please, agree with the l\\'Privacy Policy','registrazione-utenti') );\r\n\t\t\t}\r\n\t\t}\r\n \r\n        return $errors;\r\n    }<\/pre>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<h3 class=\"wp-block-heading\"><br \/>3. How to save the data of the user who has just registered?<\/h3>\r\n<p>&nbsp;<\/p>\r\n\r\n<p>New metadata for the new user must be saved, using the <a href=\"http:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\/user_register\">user_register<\/a> Hook. The Hook allows us to access the information of the new user immediately after being added to the Database.<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<pre class=\"wp-block-syntaxhighlighter-code\">add_action('user_register', 'myplugin_user_register');\r\n    function myplugin_user_register ($user_id) {\r\n        if ( isset( $_POST['first_name'] ) )\r\n            update_user_meta($user_id, 'first_name', $_POST['first_name']);\r\n\t\tif ( isset( $_POST['last_name'] ) )\r\n            update_user_meta($user_id, 'last_name', $_POST['last_name']);\r\n\t\tif ( isset( $_POST['nickname'] ) )\r\n            update_user_meta($user_id, 'nickname', $_POST['nickname']);\r\n        if ( isset( $_POST['privacy_policy'] ) )\r\n            update_user_meta($user_id, 'privacy_policy', $_POST['privacy_policy']);\r\n    }<\/pre>\r\n\r\n<p>&nbsp;<\/p>\r\n<p>The user&#8217;s metadata is added by <a href=\"http:\/\/codex.wordpress.org\/Function_Reference\/update_user_meta\">update_user_meta<\/a> as soon as they are entered by passing its <strong>ID<\/strong> as parameters, the name of the <strong>meta value.<\/strong><\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<h2 class=\"wp-block-heading\"><br \/>4. How to view data in the Back End?<\/h2>\r\n\r\n<p>Within the <strong>wp_usermeta<\/strong> table all data are saved, but they are not visible in the Back End, in our case you will not only see Privacy Policy, because the other changes use by default those of WordPress (eg <strong>$ first_name, $ last_name, etc<\/strong> ). To overcome this obstacle, we must create a special section for the Back End and be able to display additional information within the profile of each individual user. In the code below we make the data entered during the recording visible on the user profile page.<\/p>\r\n<p>There are two different <strong>Hooks<\/strong> as you can see, because WordPress allows you to differentiate profile views depending on whether the site owner is viewing it, or another user. In our example we do not deal with this particular case study and the profile will simply appear with additional information.<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<pre class=\"wp-block-syntaxhighlighter-code\"> add_action('show_user_profile','show_the_new_meta_values'); \/\/ Hook used when a user is viewing their profile\r\n add_action('edit_user_profile','show_the_new_meta_values'); \/\/ Hook used when a user is viewing another user's profile\r\n \r\n function show_the_new_meta_values($user)\r\n {\r\n \r\n    $privacyPolicy = get_user_meta($user-&gt;ID, 'privacy_policy', true);\r\n\r\n    if (get_locale() == 'it_IT') { ?&gt;\r\n\t&lt;h3&gt;&lt;?php _e('Informazioni aggiuntive','registrazione-utenti')?&gt;&lt;\/h3&gt;\r\n\t\t&lt;table class=\"form-table\"&gt;\r\n            &lt;tr&gt;\r\n\t\t\t\t&lt;th&gt;&lt;label for=\"privacy_policy\"&gt;&lt;?php _e('Consenso informativa sulla Privacy Policy','registrazione-utenti') ?&gt;&lt;\/label&gt;&lt;\/th&gt;\r\n\t\t\t\t&lt;td&gt;&lt;input type=\"checkbox\" name=\"privacy_policy\" value=\"1\" aria-invalid=\"false\" &lt;?php if ($privacyPolicy == \"1\") { echo \"checked\"; } else { echo \"\"; } ?&gt;&gt;&lt;span&gt; Consenso all'INFORMATIVA SULLA PRIVACY&lt;\/span&gt;&lt;\/td&gt;\r\n\t\t\t&lt;\/tr&gt;\r\n\t\t&lt;\/table&gt;\r\n\r\n\t&lt;?php } else { ?&gt;\r\n\t\t\r\n\t\t&lt;h3&gt;&lt;?php _e('Additional information','registrazione-utenti')?&gt;&lt;\/h3&gt;\r\n\t\t&lt;table class=\"form-table\"&gt;\r\n            &lt;tr&gt;\r\n\t\t\t\t&lt;th&gt;&lt;label for=\"privacy_policy\"&gt;&lt;?php _e('Consent information on the Privacy Policy','registrazione-utenti') ?&gt;&lt;\/label&gt;&lt;\/th&gt;\r\n\t\t\t\t&lt;td&gt;&lt;input type=\"checkbox\" name=\"privacy_policy\" value=\"1\" aria-invalid=\"false\" &lt;?php if ($privacyPolicy == \"1\") { echo \"checked\"; } else { echo \"\"; } ?&gt;&gt;&lt;span&gt; Consent to the PRIVACY POLICY&lt;\/span&gt;&lt;\/td&gt;\r\n\t\t\t&lt;\/tr&gt;\r\n\t\t&lt;\/table&gt;\r\n\r\n\t&lt;?php }\r\n }<\/pre>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p>Our result will be this in the picture:<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p><img loading=\"lazy\" decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/ywAAAAAAQABAAACAUwAOw==\" fifu-lazy=\"1\" fifu-data-sizes=\"auto\" fifu-data-srcset=\"https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=75&resize=75&ssl=1 75w, https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=100&resize=100&ssl=1 100w, https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=150&resize=150&ssl=1 150w, https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=240&resize=240&ssl=1 240w, https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=320&resize=320&ssl=1 320w, https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=500&resize=500&ssl=1 500w, https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=640&resize=640&ssl=1 640w, https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=800&resize=800&ssl=1 800w, https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=1024&resize=1024&ssl=1 1024w, https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=1280&resize=1280&ssl=1 1280w, https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1&w=1600&resize=1600&ssl=1 1600w\" class=\"alignnone size-medium\" fifu-data-src=\"https:\/\/i1.wp.com\/i.ibb.co\/pjC5SCB\/Additional-information.png?ssl=1\" width=\"775\" height=\"127\" \/><\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<h3 class=\"wp-block-heading\"><br \/>5. Our conclusions<\/h3>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p>Here is the complete code of our Guide:<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<pre class=\"wp-block-syntaxhighlighter-code\">&lt;?php\r\n\r\n\/*\r\nPlugin Name: WP Custom Register Form\r\nVersion: 1.0\r\nDescription: A simple plugin to customize the fields in the user registration of WordPress\r\nAuthor: SviluppoMania.com\r\nAuthor URI: http:\/\/www.sviluppomania.com\r\nLicense: GPLv2 or later\r\nLicense URI: http:\/\/www.gnu.org\/licenses\/gpl-2.0.html\r\n\r\n==========================================\r\n\r\nLicensing information\r\n\r\nCopyright 2019 SviluppoMania (e-mail: info@sviluppomania.com)\r\n\r\nThis program is free software; you can redistribute it and \/ or modify\r\nit under the terms of the GNU General Public License, version 2, as\r\npublished by the Free Software Foundation.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program; if not, write to the Free Software\r\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\r\n\r\n*\/\r\n\r\n\r\n\r\n\r\n\/*\r\n * \/\/ Adding the new item to the registration form\r\n *\/\r\n \r\n \r\n \/\/ Adding the new item to the registration form\r\n    add_action('register_form','myplugin_register_form');\r\n \r\n    function myplugin_register_form (){\r\n        $first_name = ( isset( $_POST['first_name'] ) ) ? $_POST['first_name']: ''; \/\/ Saving the First Name field\r\n\t\t$last_name = ( isset( $_POST['last_name'] ) ) ? $_POST['last_name']: ''; \/\/ Saving the Last Name field\r\n\t\t$nickname = ( isset( $_POST['nickname'] ) ) ? $_POST['nickname']: ''; \/\/ Saving the Nickname field\r\n        $privacyPolicy = ( isset( $_POST['privacy_policy'] ) ) ? $_POST['privacy_policy']: '0'; \/\/ Saving the Privacy Policy field\r\n        \r\n\t\tif (get_locale() == 'it_IT') {\r\n        ?&gt;\r\n        &lt;p&gt;\r\n            &lt;label for=\"first_name\"&gt;&lt;?php _e('Nome','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"first_name\" id=\"first_name\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($first_name)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;p&gt;\r\n            &lt;label for=\"last_name\"&gt;&lt;?php _e('Cognome','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"last_name\" id=\"last_name\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($last_name)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;p&gt;\r\n            &lt;label for=\"nickname\"&gt;&lt;?php _e('Nickname','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"nickname\" id=\"nickname\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($nickname)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;br&gt;\r\n\t\t&lt;p&gt;\r\n\t\t&lt;input type=\"checkbox\" name=\"privacy_policy\" value=\"1\" aria-invalid=\"false\" &lt;?php if ($privacyPolicy == \"1\") { echo \"checked\"; } else { echo \"\"; } ?&gt;&gt;&lt;\/span&gt;&lt;\/span&gt;&lt;\/span&gt; ACCETTO I &lt;a href=\"https:\/\/www.sviluppomania.com\/it\/termsconditions\/\"&gt;TERMINI E CONDIZIONI D'USO&lt;\/a&gt; E L'&lt;a href=\"https:\/\/www.sviluppomania.com\/it\/privacy\/\"&gt;INFORMATIVA SULLA PRIVACY&lt;\/a&gt;.&lt;\/p&gt;\r\n\t\t&lt;br&gt;&lt;br&gt;\r\n\t\t&lt;\/p&gt;\r\n\t\t\r\n\t\t&lt;?php } else { ?&gt;\r\n\t\t\r\n\t\t&lt;p&gt;\r\n            &lt;label for=\"first_name\"&gt;&lt;?php _e('First Name','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"first_name\" id=\"first_name\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($first_name)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;p&gt;\r\n            &lt;label for=\"last_name\"&gt;&lt;?php _e('Last Name','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"surname\" id=\"last_name\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($last_name)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;p&gt;\r\n            &lt;label for=\"nickname\"&gt;&lt;?php _e('Nickname','registrazione-utenti') ?&gt;&lt;br \/&gt;\r\n                &lt;input type=\"text\" name=\"nickname\" id=\"nickname\" class=\"input\" value=\"&lt;?php echo esc_attr(stripslashes($nickname)); ?&gt;\" size=\"25\" \/&gt;&lt;\/label&gt;\r\n        &lt;\/p&gt;\r\n\t\t&lt;br&gt;\r\n\t\t&lt;p&gt;\r\n\t\t&lt;input type=\"checkbox\" name=\"privacy_policy\" value=\"1\" aria-invalid=\"false\" &lt;?php if ($privacyPolicy == \"1\") { echo \"checked\"; } else { echo \"\"; } ?&gt;&gt;&lt;\/span&gt;&lt;\/span&gt;&lt;\/span&gt; I ACCEPT THE &lt;a href=\"https:\/\/www.sviluppomania.com\/en\/termsconditions\/\"&gt;TERMS AND CONDITIONS OF USE&lt;\/a&gt; AND THE &lt;a href=\"https:\/\/www.sviluppomania.com\/en\/privacy\/\"&gt;PRIVACY POLICY&lt;\/a&gt;.&lt;\/p&gt;\r\n\t\t&lt;br&gt;&lt;br&gt;\r\n\t\t&lt;\/p&gt;\r\n\t\t\r\n\t\t&lt;?php }\r\n    }\r\n \r\n    \/\/ Validation of the entered data\r\n    add_filter('registration_errors', 'myplugin_registration_errors', 10, 3);\r\n    function myplugin_registration_errors ($errors, $sanitized_user_login, $user_email) {\r\n \r\n        if ( empty( $_POST['first_name'] ) ) \/\/ The First Name field is mandatory and can not be empty\r\n\t\t{\r\n\t\t\tif (get_locale() == 'it_IT') {\r\n\t\t\t\t$errors-&gt;add( 'first_name_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Devi inserire il tuo Nome','registrazione-utenti') );\r\n\t\t\t} else {\r\n\t\t\t\t$errors-&gt;add( 'first_name_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Please, type your first name ','registrazione-utenti') );\r\n\t\t\t}\r\n\t\t}\r\n\t\t\t\r\n\t\tif ( empty( $_POST['last_name'] ) ) \/\/ The Last Name field is mandatory and can not be empty\r\n\t\t{\r\n\t\t\tif (get_locale() == 'it_IT') {\r\n\t\t\t\t$errors-&gt;add( 'last_name_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Devi inserire il tuo Cognome','registrazione-utenti') );\t\r\n\t\t\t} else {\r\n\t\t\t\t$errors-&gt;add( 'last_name_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Please, type your last name','registrazione-utenti') );\t\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t\t\tif ( empty( $_POST['nickname'] ) ) \/\/ The Nickname field is mandatory and can not be empty\r\n\t\t{\r\n\t\t\tif (get_locale() == 'it_IT') {\r\n\t\t\t\t$errors-&gt;add( 'nickname_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Devi inserire il tuo Nickname','registrazione-utenti') );\t\r\n\t\t\t} else {\r\n\t\t\t\t$errors-&gt;add( 'nickname_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Please, type your nickname','registrazione-utenti') );\t\r\n\t\t\t}\r\n\t\t}\r\n\r\n        if ( empty( $_POST['privacy_policy'] ) || $_POST['privacy_policy'] != \"1\") \/\/ Consent to the Privacy Policy is mandatory\r\n\t\t{\r\n\t\t\tif (get_locale() == 'it_IT') {\r\n\t\t\t\t$errors-&gt;add( 'privacy_policy_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Devi accettare l\\'informativa sulla privacy','registrazione-utenti') );\r\n\t\t\t} else {\r\n\t\t\t\t$errors-&gt;add( 'privacy_policy_error', __('&lt;strong&gt;ERROR&lt;\/strong&gt;: Please, agree with the l\\'Privacy Policy','registrazione-utenti') );\r\n\t\t\t}\r\n\t\t}\r\n \r\n        return $errors;\r\n    }\r\n\t\r\n \r\n    \/\/ Data saving\r\n    add_action('user_register', 'myplugin_user_register');\r\n    function myplugin_user_register ($user_id) {\r\n        if ( isset( $_POST['first_name'] ) )\r\n            update_user_meta($user_id, 'first_name', $_POST['first_name']);\r\n\t\tif ( isset( $_POST['last_name'] ) )\r\n            update_user_meta($user_id, 'last_name', $_POST['last_name']);\r\n\t\tif ( isset( $_POST['nickname'] ) )\r\n            update_user_meta($user_id, 'nickname', $_POST['nickname']);\r\n        if ( isset( $_POST['privacy_policy'] ) )\r\n            update_user_meta($user_id, 'privacy_policy', $_POST['privacy_policy']);\r\n    }\r\n \r\n \r\n \r\n \r\n\/**************************************************\r\n *                                                *\r\n *   Display of additional data on the back end   *\r\n *                                                *\r\n *************************************************\/\r\n \r\n \r\n add_action('show_user_profile','show_the_new_meta_values'); \/\/ Hook used when a user is viewing their profile\r\n add_action('edit_user_profile','show_the_new_meta_values'); \/\/ Hook used when a user is viewing another user's profile\r\n \r\n function show_the_new_meta_values($user)\r\n {\r\n \r\n    $privacyPolicy = get_user_meta($user-&gt;ID, 'privacy_policy', true);\r\n\r\n    if (get_locale() == 'it_IT') { ?&gt;\r\n\t&lt;h3&gt;&lt;?php _e('Informazioni aggiuntive','registrazione-utenti')?&gt;&lt;\/h3&gt;\r\n\t\t&lt;table class=\"form-table\"&gt;\r\n            &lt;tr&gt;\r\n\t\t\t\t&lt;th&gt;&lt;label for=\"privacy_policy\"&gt;&lt;?php _e('Consenso informativa sulla Privacy Policy','registrazione-utenti') ?&gt;&lt;\/label&gt;&lt;\/th&gt;\r\n\t\t\t\t&lt;td&gt;&lt;input type=\"checkbox\" name=\"privacy_policy\" value=\"1\" aria-invalid=\"false\" &lt;?php if ($privacyPolicy == \"1\") { echo \"checked\"; } else { echo \"\"; } ?&gt;&gt;&lt;span&gt; Consenso all'INFORMATIVA SULLA PRIVACY&lt;\/span&gt;&lt;\/td&gt;\r\n\t\t\t&lt;\/tr&gt;\r\n\t\t&lt;\/table&gt;\r\n\r\n\t&lt;?php } else { ?&gt;\r\n\t\t\r\n\t\t&lt;h3&gt;&lt;?php _e('Additional information','registrazione-utenti')?&gt;&lt;\/h3&gt;\r\n\t\t&lt;table class=\"form-table\"&gt;\r\n            &lt;tr&gt;\r\n\t\t\t\t&lt;th&gt;&lt;label for=\"privacy_policy\"&gt;&lt;?php _e('Consent information on the Privacy Policy','registrazione-utenti') ?&gt;&lt;\/label&gt;&lt;\/th&gt;\r\n\t\t\t\t&lt;td&gt;&lt;input type=\"checkbox\" name=\"privacy_policy\" value=\"1\" aria-invalid=\"false\" &lt;?php if ($privacyPolicy == \"1\") { echo \"checked\"; } else { echo \"\"; } ?&gt;&gt;&lt;span&gt; Consent to the PRIVACY POLICY&lt;\/span&gt;&lt;\/td&gt;\r\n\t\t\t&lt;\/tr&gt;\r\n\t\t&lt;\/table&gt;\r\n\r\n\t&lt;?php }\r\n }\r\n \r\n \r\n \r\n \/\/ Data update\r\nadd_action('personal_options_update', 'update_the_new_meta_values');\r\nadd_action('edit_user_profile_update', 'update_the_new_meta_values');\r\n \r\nfunction update_the_new_meta_values($user_id)\r\n{\r\n    $new_value_first_name = $_POST['first_name'];\r\n\t$new_value_last_name = $_POST['last_name'];\r\n\t$new_value_nickname = $_POST['nickname'];\r\n    $new_value_privacy_policy = $_POST['privacy_policy'];\r\n \r\n \r\n    \/\/ Updated data\r\n    update_user_meta($user_id,'first_name',$new_value_first_name);\r\n\tupdate_user_meta($user_id,'last_name',$new_value_last_name);\r\n\tupdate_user_meta($user_id,'nickname',$new_value_nickname);\r\n    update_user_meta($user_id,'privacy_policy',$new_value_privacy_policy);\r\n \r\n \r\n    \/\/ Check that the data has been saved in the Database\r\n    if ( (get_user_meta($user_id, 'first_name', true ) != $new_value_first_name)\r\n        || (get_user_meta($user_id, 'last_name', true ) != $new_value_last_name) || (get_user_meta($user_id, 'nickname', true ) != $new_value_nickname) || (get_user_meta($user_id, 'privacy_policy', true ) != $new_value_privacy_policy) ) {\r\n        wp_die(__( 'Error while saving data on the Database','registrazione-utenti' ) );\r\n    }\r\n\t\r\n}<\/pre>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p>Every new user from now on who wishes to register on your site will have to insert some additional information, from the Back End you can easily check and \/ or modify the data entered for each user. I hope I have been clear, but if you have any doubts do not hesitate to contact us through our <a href=\"https:\/\/www.sviluppomania.com\/en\/contact-us\/\">form contact<\/a> us or comment on the article!<\/p>\r\n<p>&nbsp;<\/p>\r\n<p>Stay Tuned!<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>Sorry, this entry is only available in Italiano.<\/p>\n","protected":false},"author":1,"featured_media":7100,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/i.ibb.co\/gZ4nhjm\/example.png","fifu_image_alt":"Example","_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"categories":[298,65],"tags":[],"class_list":["post-2886","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming_languages","category-news"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to add custom fields to the registration form in WordPress?<\/title>\n<meta name=\"description\" content=\"If we want to learn more about subscribers of our website or if we need to have additional data for example: a marketing campaign, it may be useful to add a custom field or more fields to the WordPress registration form.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to add custom fields to the registration form in WordPress?\" \/>\n<meta property=\"og:description\" content=\"If we want to learn more about subscribers of our website or if we need to have additional data for example: a marketing campaign, it may be useful to add a custom field or more fields to the WordPress registration form.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"SviluppoMania | Professional blog dedicated to Technology!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SviluppoManiaCom\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/SviluppoManiaCom\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-23T17:39:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-26T16:51:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i.ibb.co\/gZ4nhjm\/example.png\" \/><meta property=\"og:image\" content=\"https:\/\/i.ibb.co\/gZ4nhjm\/example.png\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"1440\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"SviluppoMania - Francesco Candurro\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/i.ibb.co\/gZ4nhjm\/example.png\" \/>\n<meta name=\"twitter:creator\" content=\"@SviluppoMania\" \/>\n<meta name=\"twitter:site\" content=\"@SviluppoMania\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"SviluppoMania - Francesco Candurro\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"33 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/it\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/it\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/\"},\"author\":{\"name\":\"SviluppoMania - Francesco Candurro\",\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/it\\\/#\\\/schema\\\/person\\\/1b9aaf318f92db3d302d72831f6a3268\"},\"headline\":\"How to add custom fields to the registration form in WordPress?\",\"datePublished\":\"2019-02-23T17:39:38+00:00\",\"dateModified\":\"2022-06-26T16:51:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/it\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/\"},\"wordCount\":1402,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/it\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/it\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i3.wp.com\\\/i.ibb.co\\\/gZ4nhjm\\\/example.png?w=1054&resize=1054,921&ssl=1\",\"articleSection\":[\"PROGRAMMING &amp; LANGUAGES\",\"NEWS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.sviluppomania.com\\\/it\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/\",\"url\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/\",\"name\":\"How to add custom fields to the registration form in WordPress?\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/it\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i3.wp.com\\\/i.ibb.co\\\/gZ4nhjm\\\/example.png?w=1054&resize=1054,921&ssl=1\",\"datePublished\":\"2019-02-23T17:39:38+00:00\",\"dateModified\":\"2022-06-26T16:51:30+00:00\",\"description\":\"If we want to learn more about subscribers of our website or if we need to have additional data for example: a marketing campaign, it may be useful to add a custom field or more fields to the WordPress registration form.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[[\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/\"]]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i3.wp.com\\\/i.ibb.co\\\/gZ4nhjm\\\/example.png?w=1054&resize=1054,921&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i3.wp.com\\\/i.ibb.co\\\/gZ4nhjm\\\/example.png?w=1054&resize=1054,921&ssl=1\",\"width\":1054,\"height\":921,\"caption\":\"Example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come aggiungere campi personalizzati al form di registrazione in WordPress?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/\",\"name\":\"SviluppoMania | Professional blog dedicated to Technology!\",\"description\":\"SviluppoMania | Professional blog dedicated to Technology! Tools - Reviews and much more\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/#organization\",\"name\":\"SviluppoMania.com\",\"url\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.sviluppomania.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/SviluppoMania-logo2-_1_.webp\",\"contentUrl\":\"https:\\\/\\\/www.sviluppomania.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/SviluppoMania-logo2-_1_.webp\",\"width\":474,\"height\":408,\"caption\":\"SviluppoMania.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/SviluppoManiaCom\",\"https:\\\/\\\/x.com\\\/SviluppoMania\",\"https:\\\/\\\/www.instagram.com\\\/sviluppomania\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UC5CuM88LjzBeC23s2DPdveA\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sviluppomania.com\\\/it\\\/#\\\/schema\\\/person\\\/1b9aaf318f92db3d302d72831f6a3268\",\"name\":\"SviluppoMania - Francesco Candurro\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/lh3.googleusercontent.com\\\/a\\\/ACg8ocJXHCCgks_jz9HSfaD4_qV-gr2359EvQn4jBFt_CzJU8Y79iyGp=s96-c?sz=50\",\"url\":\"https:\\\/\\\/lh3.googleusercontent.com\\\/a\\\/ACg8ocJXHCCgks_jz9HSfaD4_qV-gr2359EvQn4jBFt_CzJU8Y79iyGp=s96-c?sz=50\",\"contentUrl\":\"https:\\\/\\\/lh3.googleusercontent.com\\\/a\\\/ACg8ocJXHCCgks_jz9HSfaD4_qV-gr2359EvQn4jBFt_CzJU8Y79iyGp=s96-c?sz=50\",\"caption\":\"SviluppoMania - Francesco Candurro\"},\"sameAs\":[\"https:\\\/\\\/www.sviluppomania.com\\\/\",\"https:\\\/\\\/www.facebook.com\\\/SviluppoManiaCom\",\"https:\\\/\\\/www.instagram.com\\\/sviluppomania\\\/\",\"https:\\\/\\\/x.com\\\/SviluppoMania\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UC5CuM88LjzBeC23s2DPdveA\"],\"url\":\"https:\\\/\\\/www.sviluppomania.com\\\/en\\\/author\\\/sviluppomania\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to add custom fields to the registration form in WordPress?","description":"If we want to learn more about subscribers of our website or if we need to have additional data for example: a marketing campaign, it may be useful to add a custom field or more fields to the WordPress registration form.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"How to add custom fields to the registration form in WordPress?","og_description":"If we want to learn more about subscribers of our website or if we need to have additional data for example: a marketing campaign, it may be useful to add a custom field or more fields to the WordPress registration form.","og_url":"https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/","og_site_name":"SviluppoMania | Professional blog dedicated to Technology!","article_publisher":"https:\/\/www.facebook.com\/SviluppoManiaCom","article_author":"https:\/\/www.facebook.com\/SviluppoManiaCom","article_published_time":"2019-02-23T17:39:38+00:00","article_modified_time":"2022-06-26T16:51:30+00:00","og_image":[{"url":"https:\/\/i.ibb.co\/gZ4nhjm\/example.png","type":"","width":"","height":""},{"url":"https:\/\/i.ibb.co\/gZ4nhjm\/example.png","width":960,"height":1440,"type":"image\/jpeg"}],"author":"SviluppoMania - Francesco Candurro","twitter_card":"summary_large_image","twitter_image":"https:\/\/i.ibb.co\/gZ4nhjm\/example.png","twitter_creator":"@SviluppoMania","twitter_site":"@SviluppoMania","twitter_misc":{"Written by":"SviluppoMania - Francesco Candurro","Est. reading time":"33 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sviluppomania.com\/it\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/#article","isPartOf":{"@id":"https:\/\/www.sviluppomania.com\/it\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/"},"author":{"name":"SviluppoMania - Francesco Candurro","@id":"https:\/\/www.sviluppomania.com\/it\/#\/schema\/person\/1b9aaf318f92db3d302d72831f6a3268"},"headline":"How to add custom fields to the registration form in WordPress?","datePublished":"2019-02-23T17:39:38+00:00","dateModified":"2022-06-26T16:51:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sviluppomania.com\/it\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/"},"wordCount":1402,"commentCount":0,"publisher":{"@id":"https:\/\/www.sviluppomania.com\/it\/#organization"},"image":{"@id":"https:\/\/www.sviluppomania.com\/it\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/i3.wp.com\/i.ibb.co\/gZ4nhjm\/example.png?w=1054&resize=1054,921&ssl=1","articleSection":["PROGRAMMING &amp; LANGUAGES","NEWS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.sviluppomania.com\/it\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/","url":"https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/","name":"How to add custom fields to the registration form in WordPress?","isPartOf":{"@id":"https:\/\/www.sviluppomania.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/#primaryimage"},"image":{"@id":"https:\/\/www.sviluppomania.com\/it\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/i3.wp.com\/i.ibb.co\/gZ4nhjm\/example.png?w=1054&resize=1054,921&ssl=1","datePublished":"2019-02-23T17:39:38+00:00","dateModified":"2022-06-26T16:51:30+00:00","description":"If we want to learn more about subscribers of our website or if we need to have additional data for example: a marketing campaign, it may be useful to add a custom field or more fields to the WordPress registration form.","breadcrumb":{"@id":"https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":[["https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/"]]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/#primaryimage","url":"https:\/\/i3.wp.com\/i.ibb.co\/gZ4nhjm\/example.png?w=1054&resize=1054,921&ssl=1","contentUrl":"https:\/\/i3.wp.com\/i.ibb.co\/gZ4nhjm\/example.png?w=1054&resize=1054,921&ssl=1","width":1054,"height":921,"caption":"Example"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sviluppomania.com\/en\/come-aggiungere-campi-personalizzati-al-form-di-registrazione-in-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sviluppomania.com\/en\/"},{"@type":"ListItem","position":2,"name":"Come aggiungere campi personalizzati al form di registrazione in WordPress?"}]},{"@type":"WebSite","@id":"https:\/\/www.sviluppomania.com\/en\/#website","url":"https:\/\/www.sviluppomania.com\/en\/","name":"SviluppoMania | Professional blog dedicated to Technology!","description":"SviluppoMania | Professional blog dedicated to Technology! Tools - Reviews and much more","publisher":{"@id":"https:\/\/www.sviluppomania.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sviluppomania.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.sviluppomania.com\/en\/#organization","name":"SviluppoMania.com","url":"https:\/\/www.sviluppomania.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sviluppomania.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.sviluppomania.com\/wp-content\/uploads\/2020\/12\/SviluppoMania-logo2-_1_.webp","contentUrl":"https:\/\/www.sviluppomania.com\/wp-content\/uploads\/2020\/12\/SviluppoMania-logo2-_1_.webp","width":474,"height":408,"caption":"SviluppoMania.com"},"image":{"@id":"https:\/\/www.sviluppomania.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SviluppoManiaCom","https:\/\/x.com\/SviluppoMania","https:\/\/www.instagram.com\/sviluppomania\/","https:\/\/www.youtube.com\/channel\/UC5CuM88LjzBeC23s2DPdveA"]},{"@type":"Person","@id":"https:\/\/www.sviluppomania.com\/it\/#\/schema\/person\/1b9aaf318f92db3d302d72831f6a3268","name":"SviluppoMania - Francesco Candurro","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lh3.googleusercontent.com\/a\/ACg8ocJXHCCgks_jz9HSfaD4_qV-gr2359EvQn4jBFt_CzJU8Y79iyGp=s96-c?sz=50","url":"https:\/\/lh3.googleusercontent.com\/a\/ACg8ocJXHCCgks_jz9HSfaD4_qV-gr2359EvQn4jBFt_CzJU8Y79iyGp=s96-c?sz=50","contentUrl":"https:\/\/lh3.googleusercontent.com\/a\/ACg8ocJXHCCgks_jz9HSfaD4_qV-gr2359EvQn4jBFt_CzJU8Y79iyGp=s96-c?sz=50","caption":"SviluppoMania - Francesco Candurro"},"sameAs":["https:\/\/www.sviluppomania.com\/","https:\/\/www.facebook.com\/SviluppoManiaCom","https:\/\/www.instagram.com\/sviluppomania\/","https:\/\/x.com\/SviluppoMania","https:\/\/www.youtube.com\/channel\/UC5CuM88LjzBeC23s2DPdveA"],"url":"https:\/\/www.sviluppomania.com\/en\/author\/sviluppomania\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sviluppomania.com\/en\/wp-json\/wp\/v2\/posts\/2886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sviluppomania.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sviluppomania.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sviluppomania.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sviluppomania.com\/en\/wp-json\/wp\/v2\/comments?post=2886"}],"version-history":[{"count":0,"href":"https:\/\/www.sviluppomania.com\/en\/wp-json\/wp\/v2\/posts\/2886\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sviluppomania.com\/en\/wp-json\/wp\/v2\/media\/7100"}],"wp:attachment":[{"href":"https:\/\/www.sviluppomania.com\/en\/wp-json\/wp\/v2\/media?parent=2886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sviluppomania.com\/en\/wp-json\/wp\/v2\/categories?post=2886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sviluppomania.com\/en\/wp-json\/wp\/v2\/tags?post=2886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}