Adding Field in Woocommerce registration form template

3492

You will find the template in plugin/woocommerce/templates/my-account/form-login.php and there are following hooks on there.

  • At the beginning of the form : woocommerce_register_form_start
  • Before the register button : woocommerce_register_form
  • Adding something after the register button: woocommerce_register_form_end

add_action(‘woocommerce_register_form_start’, ‘anis_add_something_beginning_form’);

function anis_add_something_beginning_form(){

woocommerce_form_field(
		'country_to_visit',
		array(
			'type'        => 'text',
			'required'    => true, // just adds an "*"
			'label'       => 'Country you want to visit the most'
		),
		( isset($_POST['country_to_visit']) ? $_POST['country_to_visit'] : '' )
	);


}