Forum Replies Created
Viewing 1 post (of 1 total)
-
AuthorPosts
-
afspnationalMemberHi Jason,
Thanks for the tip. I had found your gist before but had no luck in implementing it. Below is the code I’ve cobbled together so far. Can you let me know if I’m on the right track?
piklist('field', array( 'type' => 'datepicker' ,'scope' => 'post_meta' ,'field' => 'due_date' ,'label' => 'Due Date' ,'description' => 'Choose the due date for the project.' ,'attributes' => array( 'class' => 'text' ) ,'options' => array( 'dateFormat' => 'M d, yy' ,'firstDay' => '0' ) ,'validate' => array( array( 'type' => 'valid_date' ) ) )); add_filter('piklist_validation_rules', 'check_date'); function check_date() { $validation_rules = array( 'valid_date' => array( 'callback' => 'validate_date' ) ); return $validation_rules; } function validate_date($value, $field, $arguments) { $dates = $values[0]; $due_date = strtotime($dates['due_date']); $min_date = strtotime('-2 weeks'); if ( $min_date >= $due_date ) return __('Due date must be at least 2 weeks in advance.'); } -
AuthorPosts
Viewing 1 post (of 1 total)