• Hello Flamingo experts,
    I’m using wpcf7_after_flamingo function and I need to make a redirection with JS code but it seems that I can’t use echo in my code inside this function.
    This what I’m trying to do :
    function action_wpcf7_after_flamingo($result) {
    echo '<SCRIPT LANGUAGE="JavaScript">document.location.href="https://localhost:8888/carnet-de-vol/user/carnetdevol/"</SCRIPT>';
    }
    add_action( 'wpcf7_after_flamingo', 'action_wpcf7_after_flamingo', 10, 1 );

Viewing 6 replies - 1 through 6 (of 6 total)
  • Change the current echo’s to $variable (notice .= not just =) and then use return:

    abc_function () {
       $my_action .= '<script>...</script>';
       return $my_action;
    }
    add_action( 'wpcf7_after_flamingo', 'abc_function', 10, 1 );
    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    Hi Paul,
    thanks for your answer.
    My concern is that I need to check if variables used in wpcf7_after_flamingo function have the right value. In a regular function I can simply add an echo for this variable to check it’s value. But if I do that while using a cf7 form the process stops and I have no way to check the variable value. So is there a solution?

    • the process stops” I don’t know what’s inside the script and what the js console log shows
    • check if variables used in wpcf7_after_flamingo function have the right value” – but what values? Compare to what with what? More above when and why you need to compare the values?
    • Do you use any other Flamingo or CF7 plugins or custom code?
    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    For example, I want to make calculations from data generated by a CF7 form (therefore values contained in variables) and save the results of these calculations in the database. I therefore use the wpcf7_after_flamingo function to host the code that does these calculations and saves the results in the database. It works fine but if my code is not working correctly and I want to display a calculation result stored in a variable to check why the code is bugging using “echo $variable” it blocks the working of the form. So I’m looking for a way to display the contents of this variable without the form stopping working.

    wp_debug on? What shows? No notices or errors or warnings?

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    This is what I get from console.log

    index.js?ver=5.7.5.1:1

    1. {code: ‘invalid_json’, message: ‘The response is not a valid JSON response.’}
      1. code: “invalid_json”
      2. message: “The response is not a valid JSON response.”
      3. Prototype: Object
        1. constructor: ? Object()
        2. hasOwnProperty: ? hasOwnProperty()
        3. isPrototypeOf: ? isPrototypeOf()
        4. propertyIsEnumerable: ? propertyIsEnumerable()
        5. toLocaleString: ? toLocaleString()
        6. toString: ? toString()
        7. valueOf: ? valueOf()
        8. __defineGetter__: ? __defineGetter__()
        9. __defineSetter__: ? __defineSetter__()
        10. __lookupGetter__: ? __lookupGetter__()
        11. __lookupSetter__: ? __lookupSetter__()
        12. __proto__: (…)
        13. get __proto__: ? __proto__()
        14. set __proto__: ? __proto__()
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘wpcf7_after_flamingo’ is closed to new replies.