How to Modify the "New Customer" Form

Agents can add customers by going to their agent dashboard -> My Customers and clicking the "+Add" button.

This will open a customer registration form:

How to remove fields from the form #

To remove a field, take note of its position in the form. For example, if you want to hide "Company Name," that is the 3rd field, and you will need to add the following PHP code snippet to your site, using 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 the following 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 shown below: 

The field is linked to the "vat_number" user meta key.

Powered by BetterDocs