I need to find bug in a Wordpress site.
But I can't find the method (function) that the AJAX GET call runs on backend.
That's not admin part of website, but front end part of website.

I found the url where AJAX call is sent, but don't know how to find the method/function.

code for sending AJAX call looks like this

I have code for sending XMLHttpRequest something like this:

    var xhr = new XMLHttpRequest();
    xhr.open("GET", "http://themes.qnimate.com/qplog/wp-admin/admin-ajax.php?action=logged_in_check");
    xhr.onload = function(){

There is nothing like add_action() on frontend.

What could you advise? Any technics, advices?

  • firstly use the network monitor to look which AJAX call is send, e.g. with firefox : developer.mozilla.org/en-US/docs/Tools/Network_Monitor – mmm Apr 13 '17 at 21:00
  • hello, I found the url where AJAX call is sent, but don't know how to find the method/function. – Yurii Halapup Apr 13 '17 at 21:07
  • then edit your question and details what you have seen, without more informations it's hard to help you – mmm Apr 13 '17 at 21:10

If the url is something like this admin-ajax.php?example_ajax_request=1&data=1234

The add_action function in the code would be wp_ajax_nopriv_example_ajax_request

So, try to grep the whole of your theme directory or plugin directory for the text.

Example: grep -r 'wp_ajax_nopriv_example_ajax_request' *

The second parameter of the add_action is the function name you're looking for.

See https://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Viewer-Facing_Side for example of how it works.

  • NO it's not admin part of website. It's just front end part of website. – Yurii Halapup Apr 14 '17 at 7:27
  • I am not talking about the admin part of the website, that is why added nopriv to the function. It is for frontend only. – Mohit Apr 14 '17 at 13:13
  • For more details on nopriv refer to codex.wordpress.org/Plugin_API/Action_Reference/… – Mohit Apr 14 '17 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.