Crocoblock / jetformbuilder

80 stars 16 forks source link

[Issue] 'jet-form-builder/form-handler/after-send' hook, gets the wrong result #335

Closed bytepack closed 1 year ago

bytepack commented 1 year ago

Hi If we use Call Hook action and throw new Action_Exception( 'success' ) ) , when we use jet-form-builder/form-handler/after-send hook, the$is_success is false in the function( $handler, bool $is_success ).

According to this code, throw new Action_Exception( 'success' ) ) has success result.

rtpHarry commented 1 year ago

It looks like that code uses this:

throw ( new Action_Exception( 'Lucky!' ) )->dynamic_success();

Your suggestion is in a comment, but its from a file thats 2 years old.

I had a very brief look and it seems that what the code does is prefix it with dsuccess (dynamic success), so this MIGHT work:

throw new Action_Exception( 'dsuccess' )

But I wouldn't really want to start using internal codes when there is a method already available.

girafffee commented 1 year ago

Currently (on 3.1.8 version), with this code, $is_success returns true.

add_action(
    'jet-form-builder/custom-action/test-success',
    function () {
        throw new \Jet_Form_Builder\Exceptions\Action_Exception( 'success' );
    }
);

add_action(
    'jet-form-builder/form-handler/after-send',
    function ( $handler, $is_success ) {
        var_dump( $is_success ); die;
    },
    10,
    2
);

image