0

I am facing a problem on ajax callback.

I have an inquiry form which is added from plugin. The form works via ajax where a callback function handles the task of sending mail to admin regarding the inquiry.

I am able to alter the form fields via filter. But couldn't overwrite the callback function.

Is there a way by which I can overwrite that ajax handling callback function (coded in plugin) from theme?

Below is how that callback function is hooked:

add_action('wp_ajax_wte_enquiry_send_mail', array($this, 'wte_enquiry_send_mail') );
add_action('wp_ajax_nopriv_wte_enquiry_send_mail', array($this, 'wte_enquiry_send_mail') );

Any help will be highly appreciated.

Thank you!

4
  • look this answer wordpress.stackexchange.com/questions/293399/…
    – mmm
    Feb 9, 2018 at 11:49
  • If you're replacing the form, and the function that handles the form submission, why are you using the plugin? You're basically going to have to maintain most of the plugin code yourself by doing this. Feb 9, 2018 at 12:10
  • Hello @JacobPeattie thanks for the reply. The plugin is made by me and I am trying to make it customizable. So that anyone who uses the plugin might easily overwrite the form fields.
    – saurav.rox
    Feb 12, 2018 at 5:51
  • Requiring they unhooking the whole handler and replacing it isn't making it very customisable. A better approach might be to have a filterable list of form fields, and then the front-end and back-end refer to that list for outputting and processing the fields. Feb 12, 2018 at 5:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.