Extra User Field on Register Page
This topic contains 10 replies, has 4 voices, and was last updated by  Dotty Directory 9 years, 5 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: extra user field
- 
		AuthorPosts
- 
		
			
				
April 8, 2016 at 2:10 pm #160107Is it possible to ask for Company Name on the register page? April 8, 2016 at 5:40 pm #160201hi, I asked the developer to check if there is a filter (I believe there is) and how to use it. Thanks April 8, 2016 at 6:29 pm #160245Thank you! April 9, 2016 at 1:21 pm #160809Please use this code in your child theme’s functions.php file function whoop_add_signup_form_fields() { ?> <div class="row_spacer_registration clearfix"> <div class="form_row clearfix"> <input placeholder='Company Name' type="text" name="company" id="company" class="textfield input-text" value="" size="25"/> <span id="company_info"></span> </div> </div> <?php } add_action('social_connect_form', 'whoop_add_signup_form_fields', 1); function whoop_check_signup_form_errors($errors) { $company = esc_sql(sanitize_text_field($_POST['company'])); if ($company == '') { $errors->add('empty_company', __('ERROR: Please enter your company name.', 'geodirectory')); } return $errors; } add_filter('registration_errors', 'whoop_check_signup_form_errors'); function whoop_insert_signup_extra_fields($user_id) { $company = esc_sql(sanitize_text_field($_POST['company'])); update_user_meta($user_id, 'company', $company); } add_action('geodir_user_register', 'whoop_insert_signup_extra_fields'); add_action( 'show_user_profile', 'whoop_extra_profile_fields' ); add_action( 'edit_user_profile', 'whoop_extra_profile_fields' ); function whoop_extra_profile_fields( $user ) { ?> <h3>Extra profile information</h3> <table class="form-table"> <tr> <th><label for="company">Company</label></th> <td> <input type="text" name="company" id="company" value="<?php echo esc_attr( get_the_author_meta( 'company', $user->ID ) ); ?>" class="regular-text" /><br /> <span class="description">Please enter your Company name.</span> </td> </tr> </table> <?php } add_action( 'personal_options_update', 'whoop_save_extra_profile_fields' ); add_action( 'edit_user_profile_update', 'whoop_save_extra_profile_fields' ); function whoop_save_extra_profile_fields( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) return false; update_user_meta( $user_id, 'company', $_POST['company'] ); }April 11, 2016 at 3:10 pm #161500Thank you worked perfectly. April 11, 2016 at 3:11 pm #161501You are welcome 🙂 May 16, 2016 at 9:37 am #191987I’ve tried adding this to my site and it didnt work, is this specifically for Whoop theme? I’m not using a theme. I’m just trying to add Username field to the registration form. Thanks May 16, 2016 at 9:49 am #191992Dotty, code posted above most likely work with other themes too. Fields will be appear in geodirectory registration page. make sure you posted above code in your child theme. May 16, 2016 at 10:00 am #191995I have done that now and it is showing, is there a way to bring it to the top of the form and for it to be a username function ? The form is still identifying email address as username Thanks May 17, 2016 at 3:22 pm #192971I’m sorry but the email is used as username that could possibly be done, but would require time to study the customization and this goes beyond support May 18, 2016 at 8:03 am #193419Not a problem Giri, its something we can live with! 🙂 Thank you for your respone 
- 
		AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket