• Resolved jas

    (@jaskaranpreetsingh)


    I have custom post types and added fields using below code :

    add_filter( 'rwmb_meta_boxes', 'wp_register_meta_boxes' );

    function wp_register_meta_boxes( $meta_boxes ) {
       return $meta_boxes[] = array (...........);
    }

    Now on saving post as draft, validations of meat box created with above runs. I want to disable validations when post is saved as draft.

    Please suggest if this is possible ?

    Thanks!

    • This topic was modified 2 years, 11 months ago by jas.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Neo WhiteRabbit

    (@longnguyen89)

    Hi Jas,

    Thanks for reaching out.

    Currently, Meta Box does not support disabling the validation based on a condition.

    Thread Starter jas

    (@jaskaranpreetsingh)

    Thanks for your comments !

    Seems like possible in acf wordpress plugin, any plans to implement this ?

    Looks like validations are handled on client side https://docs.metabox.io/validation/#validation-with-input-attributes, I think applying conditions will be possible if we can completely disable metabox validations at client side and apply our custom validations on server side on post from submit. Is that possible to add validations on fields created with metabox with PHP code in custom plugin etc

    • This reply was modified 2 years, 10 months ago by jas.
    • This reply was modified 2 years, 10 months ago by jas.
    Thread Starter jas

    (@jaskaranpreetsingh)

    For example using hook such as :

    add_filter('wp_insert_post_data','callback_function');

    or using save_post hook etc

    • This reply was modified 2 years, 10 months ago by jas.
    Thread Starter jas

    (@jaskaranpreetsingh)

    I have solved it in different way using this action add_action('save_post', 'my_custom_save_post');

    • This reply was modified 2 years, 10 months ago by jas.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to disable validations when saving draft ?’ is closed to new replies.