Support

Account

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…