Support

Account

Home Forums General Issues Trying to check for number Reply To: Trying to check for number

  • Hi @vgledhill

    You can make use casting to explicitly declare a saved value into the type that you desire.
    Here is an example:

    <?php
     //code goes in functions.php file
    function my_acf_format_value( $value, $post_id, $field ) {
    	
    	// cast the value returned by all text field into integers
    	$value = (int)$value;
    	
    	
    	// return
    	return $value;
    }
    
    add_filter('acf/format_value/type=text', 'my_acf_format_value', 10, 3);
     
    ?>

    I hope this info helps.