Tour Master – Custom Fields in Register form

The docs for developer mean you must have knowledge and coding skill. Although, we’re create the docs for developer to help you achieve something not available in original feature, but we don’t provide support for anything not work when you reference with docs for developer. If the example code not work for you, please debug it by your-self or hire a freelancer to debug it for you instead.

All the customize will lose when you update our theme/plugin to new version in future. To avoid it, you must use filter and action: https://developer.wordpress.org/plugins/hooks/.

Sometimes, you will need to customize the register form to your need, that’s why we’re writing this tutorial.

– To add the customize field in the register form, please take a look at this file: \wp-content\plugins\tourmaster\include\user-util.php around line 660. You will see the default code like this:

	if( !function_exists('tourmaster_get_profile_fields') ){
		function tourmaster_get_profile_fields(){
			return apply_filters('tourmaster_profile_fields', array(
				'first_name' => array(
					'title' => esc_html__('First Name', 'tourmaster'),
					'type' => 'text',
					'required' => true
				),
				'last_name' => array(
					'title' => esc_html__('Last Name', 'tourmaster'),
					'type' => 'text',
					'required' => true
				),
				'gender' => array(
					'title' => esc_html__('Gender', 'tourmaster'),
					'type' => 'combobox',
					'options' => array(
						'' => '-',
						'male' => esc_html__('Male', 'tourmaster'),
						'female' => esc_html__('Female', 'tourmaster')
					)
				),
				'birth_date' => array(
					'title' => esc_html__('Birth Date', 'tourmaster'),
					'type' => 'date',
					'required' => true
				),
				'email' => array(
					'title' => esc_html__('Email', 'tourmaster'),
					'type' => 'email',
					'required' => true
				),
				'phone' => array(
					'title' => esc_html__('Phone', 'tourmaster'),
					'type' => 'text',
					'required' => true
				),
				'country' => array(
					'title' => esc_html__('Country', 'tourmaster'),
					'type' => 'combobox',
					'options' => tourmaster_get_country_list(),
					'required' => true,
					'default' => tourmaster_get_option('general', 'user-default-country', '')
				),
				'contact_address' => array(
					'title' => esc_html__('Contact Address', 'tourmaster'),
					'type' => 'textarea'
				),
			));
		}
	}	

You can add a new custom field like this after the contact_address field.

				'contact_address' => array(
					'title' => esc_html__('Contact Address', 'tourmaster'),
					'type' => 'textarea'
				),
				'your_custom_field' => array(
					'title' => esc_html__('New field', 'tourmaster'),
					'type' => 'textarea'
				),

You can change the custom field type to: combobox, text, date, and textarea. You can try to check the register form now.