Can an action callback prevent the parent from continuing execution?
I'm working on a plugin that interacts with Gravity Forms, and under certain conditions I want to prevent a form from being deleted. Here's the method in Gravity Forms that handles deleting a form:
public static function delete_form($form_id){
global $wpdb;
if(!GFCommon::current_user_can_any("gravityforms_delete_forms"))
die(__("You don't have adequate permission to delete forms.", "gravityforms"));
do_action("gform_before_delete_form", $form_id);
$form_meta_table = self::get_meta_table_name();
$form_table = self::get_form_table_name();
//Deleting form Entries
self::delete_leads_by_form($form_id);
//Delete form meta
$sql = $wpdb-prepare("DELETE FROM $form_meta_table WHERE form_id=%d", $form_id);
$wpdb-query($sql);
//Deleting form Views
self::delete_views($form_id);
//Delete form
$sql = $wpdb-prepare("DELETE FROM $form_table WHERE id=%d", $form_id);
$wpdb-query($sql);
do_action("gform_after_delete_form", $form_id);
}
Is it possible to hook into gform_before_delete_form
and then do something to make delete_form() return at that point without continuing? e.g.,
public function preventGravityFormDeletion()
{
if( $someCondition )
{
// do something that forces delete_form() to stop
}
}
add_action( 'gform_before_delete_form', array( $this, 'preventGravityFormDeletion' ) );
I know that I could call wp_die()
and just stop everything, but that's not very elegant. Is there a better way? It doesn't seem possible because of scope limitations, but I wanted to check in case there's some WP/PHP magic that I'm not aware of.
Topic callbacks plugin-gravity-forms actions Wordpress
Category Web