0

I am registering and enqueuing the script in my file functions.php I got a white page and a console error 500

add_action( 'ninja_forms_insert_sub', 'ninja_forms_coregistration', 4 );
function ninja_forms_coregistration($sub_id){
    global $ninja_forms_processing;
    if( isset($ninja_forms_processing) && $ninja_forms_processing->data  AND  @$ninja_forms_processing->data['form']['sub_id'] ){
        $form = $ninja_forms_processing->data['form'] ;

        if($ninja_forms_processing->data['form_ID'] == 3){
            wp_enqueue_script('reworldmedia-ninja-forms-allianz-scripts', get_template_directory_uri().'/assets/javascripts/ninja-forms-allianz.js');
        }
        coregistration_send( $form, $ninja_forms_processing );
    }
}

Here is my js file content:

jQuery(document).ready( function(){ 
    $(".ninja-forms-cont .ninja-forms-form").submit( function() {
        send_GA( "click-submit-form-allianz","submit","click sur allianz form" );
        return false;
    }); 
});
Afaf
  • 654
  • 1
  • 5
  • 17

2 Answers2

0

You need to register the script first, then enqueue it.

To do this, change:

wp_enqueue_script('reworldmedia-ninja-forms-allianz-scripts', get_template_directory_uri().'/assets/javascripts/ninja-forms-allianz.js');

To the following:

wp_register_script('reworldmedia-ninja-forms-allianz-scripts',      
get_template_directory_uri().'/assets/javascripts/ninja-forms-allianz.js');
wp_enqueue_style('reworldmedia-ninja-forms-allianz-scripts')
Adam McKenna
  • 2,295
  • 6
  • 30
  • 41
0

You are not getting the real error message. Try enabling debugging on the functions.php file. Add this to the top of the funuctions.php page.

<?php

// Turn off all error reporting
error_reporting(0);

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);

// Report all PHP errors (see changelog)
error_reporting(E_ALL);

// Report all PHP errors
error_reporting(-1);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

?>