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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.