• Resolved wmclaxton

    (@wmclaxton)


    I have two very similar plugins attempting to perform post-processing for Ninja Forms. The first one is working fine, however it appears that the second one is not being processed during form submission.

    Here are the two different filters and note that: (a) these are in two different plugins, both of which are activated, and (b) for the form which uses id 7, it is being processed by the first plugin but not the second one.

    add_filter('ninja_forms_submit_data', 'ninja_forms_submit_data');
    function ninja_forms_submit_data($form_data) {
      // process form id 3, 4 and 5 - this is working fine
      return $form_data;
    }
    add_filter('ninja_forms_submit_data', 'model2_ninja_forms_submit_data');
    function model2_ninja_forms_submit_data($form_data) {
      // process form id 7 - this one never gets called
      return $form_data;
    }

    Can someone suggest what might be wrong with having two similar filters for the same forms?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey @wmclaxton

    First thing I’d suggest is to make sure that the line
    add_filter('ninja_forms_submit_data', 'model2_ninja_forms_submit_data');
    is being executed, and that it is executed prior to the moment that the apply_filters() methos is triggered by Ninja Forms.

    There are many other things to check, but I don’t have enough information.
    For instance, what is the scope were function model2_ninja_forms_submit_data() is declared. Your filter assumes that it is declared in the global scope.
    If the code is placed into a class, then you need to add the instance reference to the callable.
    Like this
    add_filter('ninja_forms_submit_data', array($this, 'model2_ninja_forms_submit_data'));

    Let me know if this helps. 🙂

    Since you’ve left out the code, can we assume that both filters are returning the data that is being checked (for id 7)?
    It looks as though they are using the same default priority of 10, so you can’t control which one runs first, since you can’t control which plugin is loaded first (although it might be alphabetical by plugin slug, but no guarantees).
    If the add_filter call is inside a function, it could be that it’s not executed before the form is processed.

    Thread Starter wmclaxton

    (@wmclaxton)

    Oh my, I see that my second plugin was creating its own log in a different location, ie- in the folder where the plugin resides. So, false alarm, both filters were in fact running all along.

    Thank you for your suggestions.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Filter is not being processed’ is closed to new replies.