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
评论列表(0条)