gistfile1.php

gistfile1.php

<?php 

add_filter('submit_job_form_validate_fields', 'check_price_job_field');

function check_price_job_field( $has_error, $fields, $values ){
	
	// Return true if this field doesn't exist (to prevent errors if you dont have field created)
	if( ! isset( $values['job']['price'] ) ) return true;
	
	if( empty( $values['job']['price'] ) || ! is_float( $values['job']['price'] ) ){
		throw new Exception( __( 'The custom field value must be numerical with 2 decimal places' ) );
	}
	
	// Return true to not have any errors and allow form to continue
	return true;
	
}
No comments yet.

Leave a Reply