• vmallder

    (@vmallder)


    Hello,

    I have a question about the vfb_confirmation action hook. I have registered a function for the vfb_confirmation hook and it is being called twice each time a form is submitted. This is a problem for me because I am storing data from the form into my database inside my vfb_action_confirmation function, and I do not want to store the data twice.

    The first time my vfb_action_confirmation function is called, it is because the Visual_Form_Builder::confirmation method is registered for the WordPress “init” hook on line 146 of visual-form-builder.php. The second time my vfb_action_confirmation function is called is from line 25 of form-output.php.

    At the beginning of my vfb_action_confirmation function, I have the following code:

    `if ( !isset( $_REQUEST[‘vfb-submit’] ) )
    return;`
    But, that test fails in both cases, and does not prevent the body of the function from being excecuted twice each time the form is submitted.

    How can I ensure that the body of my action function will be executed only once when a form is submitted? What other variables should I be checking at the beginning of my vfb_action_confirmation function to determine whether to execute the function or return?

    Thank you

    https://wordpress.org/plugins/visual-form-builder/

Viewing 1 replies (of 1 total)
  • I had a similar question because in my case it sent two SMSses connected to a BulkSMS gateway.

    I found this link:
    https://github.com/mattwithoos/WP-VFBP-2-SF/blob/master/wpvfbp2sf.php

    Essentially install some session code setting and checking before sending.

    if(!isset($_SESSION[‘RUNS’])) { // Prevents ‘issue’ caused by WP Visual Form Builder Pro where it runs script twice
    $_SESSION[‘RUNS’] = 1;
    }

    if($_SESSION[‘RUNS’] == 1) {
    // Do something

    // your stuff here

    // At the end
    $_SESSION[‘RUNS’]++;
    } else {
    unset($_SESSION[‘RUNS’]);
    }

Viewing 1 replies (of 1 total)
  • The topic ‘vfb_action_confirmation called twice when form is submitted’ is closed to new replies.