How to abort a save operation with a WordPress hook?

I have a WooCommerce and Dokan website.I wrote a new plugin that is supposed to do some backend form validation on cus

I have a WooCommerce and Dokan website. I wrote a new plugin that is supposed to do some backend form validation on custom fields before performing an insert or update operation. I am having problems using PHP code to abort a save operation when form validation fails. This piece of code taken from this answer is able to abort an INSERT operation

function disable_save( $maybe_empty, $postarr ) {
    $maybe_empty = true;

    return $maybe_empty;
}
add_filter( 'wp_insert_post_empty_content', 'disable_save', 0, 2 );

But it does not work for an update operation.

I even went right into the wp-includes/post.php file and changed the wp_update_post() function to return 0 on the first line, but it does not prevent the update operation from occurring.

How do I gracefully prevent a save operation with a WordPress hook in a WooCommerce + Dokan project?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745462820a4628785.html

相关推荐

  • How to abort a save operation with a WordPress hook?

    I have a WooCommerce and Dokan website.I wrote a new plugin that is supposed to do some backend form validation on cus

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信