How to Modify the "New Customer" Form

Agents can add customers by going to their agent dashboard -> my customers and clicking on the "+add" button.

That will open up a customer registration form:

How to remove fields from the form #

To remove a field, take note of the order of the field. If you are looking to hide "Company name", that is the 3rd field, and you will need to add this PHP code snippet to your site, with the number 3:

add_action('salesking_dashboard_head', function(){
	?>
	<style type="text/css">
		#salesking_add_customer_form .form-group:nth-child(3){
		    display: none;
		}
	</style>
	<?php
});

How to add a new field to the form #

To add a field, you can use this code snippet:

add_action('salesking_add_customer_custom_fields', function(){
    ?>
    <div class="form-group">
        <label class="form-label"><?php esc_html_e('Vat Number','salesking'); ?></label>
        <div class="form-control-wrap">
            <input type="text" class="form-control" id="salesking_field_new_field" name="new-field">
        </div>
    </div>
    <?php
});
add_filter('salesking_custom_fields_code_list_comma', function($val){
    $val = 'new_field';
    return $val;
}, 10, 1);
add_action('salesking_after_customer_created', function($user_id){
    if (isset($_POST['new_field'])){
        $value = sanitize_text_field($_POST['new_field']);
        update_user_meta($user_id,'vat_number', $value);
    }
}, 10, 1);

This code adds a new field for "vat_number" as follows: 

The field is connected with the "vat_number" user meta key.

Powered by BetterDocs