Home › Forums › ACF PRO › Is it possible to apply validation to draft post? › Reply To: Is it possible to apply validation to draft post?
Hi @james
I am very sorry for my long and impolite silence.
Here’s my test validation code going with a ACF setting of 1 text field named as ‘test’.
add_filter( 'acf/validate_value/name=test','my_acf_validatrion', 10, 4);
function my_acf_validatrion( $valid, $value, $field, $input ){
if( !$valid || $value == '' ) {
return true;
}
if ( $value != 'a' ) {
return 'bad input';
}
return $valid;
}
validation works
– publish > publish
– draft > publish
validation doesn’t work
– publish > draft
– draft > draft
– new > draft (newly posted one)
I wanna know the behavior above is by design or not…
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.