• Resolved artyus

    (@artyus)


    Hey!

    I tried to use wpcf7_mail_sent, wpcf7_submit, wpcf7_before_send_mail hooks, but each time an error message came out in the console:
    Object { code: "invalid_json", message: "The response is not a valid JSON response." }

    At the same time, sending the form freezes on a spinning spinner.

    The problem has been observed for several months, users have found a solution in changing the TRUE to the FALSE in the definition of WPCF7_load_JS:

    instead

    if ( ! defined( 'WPCF7_LOAD_JS' ) ) {
    	define( 'WPCF7_LOAD_JS', true );
    }

    need

    if ( ! defined( 'WPCF7_LOAD_JS' ) ) {
    	define( 'WPCF7_LOAD_JS', false );
    }

    Only if don’t load your plugin scripts, the hooks of your plugin begin to work. Obviously, the plugin code has an error or conflict.

    I can confirm that the problem is not related to other plugins or themes. I tested on a site where only your plugin was activated. The audit was carried out, including with the latest standard themes (Twenty Twenty-One, Twenty Twenty-Two etc.).

    I hope that you will quickly find the problem and eliminate it, and users will be able to continue to use all the possibilities of your excellent and popular plugin.

    Sincerely,
    Farid Taziev.

    • This topic was modified 2 years, 7 months ago by artyus.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the website in question?

    Thread Starter artyus

    (@artyus)

    Page with standard form on website:
    https://test.faridtaziev.com/aaa/

    Sample of code placed in functions.php:

    add_filter ('wpcf7_mail_sent', 'Test');
    
    function Test() {
        ...);
    }
    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Your functions.php code looks incorrect at all.

    Thread Starter artyus

    (@artyus)

    This is a child theme.

    I switched to Twenty Twenty-Two, if that’s more convenient for you.

    Thread Starter artyus

    (@artyus)

    To demonstrate the problem, I put in “functions.php” a simple code, which looks like this:

    add_filter ('wpcf7_mail_sent', 'Test');
    
    $__pageREQUEST_URI = $_SERVER['REQUEST_URI'];
    
    function Test() {
        global $__pageREQUEST_URI;
        echo("<script>console.log('$__pageREQUEST_URI');</script>");
    }
    Thread Starter artyus

    (@artyus)

    I repeat, the plugin doesn’t work even with the simplest code, regardless of how to apply a hook: with add_filter or add_action.

    Thread Starter artyus

    (@artyus)

    Ok, the problem was that plugin scripts don’t like strings output.
    The problem is not solved, but at least identified.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘The JS-scripts of the plugin violate the use of plugin hooks’ is closed to new replies.