Skip Navigation

[Closed] die() won't be fired

This support ticket is created 2 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#2117377

Just curious: why here the die() won't be fired?

add_action( 'cred_before_save_data', 'check_die', 10, 1 );
function check_die( $form_data ){
	die();
}
#2118211

Just curious: why here the die() won't be fired?
The code looks okay, and in a quick test it does seem to be working when I add it to my local test site. I tested with a create Post form, and the submission was blocked by this die() function. No new post was created. It could be failing in your case if:
- The Form submission was not successful. For example, if the Form is a Create User Form and the User already exists, that would result in an unsuccessful submission. Or for example, some validation error is thrown and the post or User is not created or edited.
- The Form is not a Toolset Post Form or a Toolset User Form. For example, Toolset's Relationship Forms have no available APIs. The existing Forms API hooks like cred_form_validate, cred_save_data, cred_submit_complete, and cred_before_save_data unfortunately do not apply to Relationship Forms, only to Post Forms and User Forms. Toolset's login forms created with wpv-login-form do not trigger these API hooks.
- The Form uses AJAX for submission and does not redirect to a different page. Even though die() was triggered, it may not be obvious in some scenarios.

You can try adding some text in the die() function to see if the text appears on the page somewhere:

die('test die message');

If it is still not clear, I can take a closer look.

The topic ‘[Closed] die() won't be fired’ is closed to new replies.