Does WordPress provide a way of rolling back when using, for example, update_post_meta
or wp_insert_post
?
E.g. I'm inserting a new post and giving it some post meta inside one function:
some_wp_transaction_init_function();
try{
$post_id = wp_insert_post($args, true);
update_post_meta($post_id, 'meta_key', 'meta_value');
}catch(Exception $e){
some_wp_rollback_function();
}
some_wp_commit_function();
Or do I have to use vanilla SQL, or the $wpdb
object?
Thanks
$wpdb->query( "START TRANSACTION" )
etc.