In part 5 of this tutorial series we wrote the Javascript that is responsible for firing off the ajax events when a user is followed or unfollowed. Now, in this part, we are going to write the PHP side of the ajax events that takes care of processing the requests and sending a response back to our Javascript.

You must be logged in and have an active premium membership to view the rest of this content. Register or login from the sidebar.

Join now to gain access to this tutorial and more.

Join Now
  1. Robert Austin


    Great series. I do have a couple of questions though.

    1) In the article you say “You may recall that in the previous part we setup a JS variable called “ajaxurl” that points to the core WordPress admin-ajax.php file”.

    If that is the case why would the $_POST[‘user_id’] and $_POST[‘follow_id’] get posted to the Actions.php script?

    2) What does “wp_ajax_follow” refer to. To my understanding the first part of an add_action call should be the “point” when you wish the function to be called. In this case it looks like you have generated your own custom point where you can plug into a plug-in (so to speak). But I can’t find the “wp_ajax_follow” do_action call. I may have missed it though.


    Robert Austin

    • Pippin

      1). The actions.php file simply holds this functions, but the actual processing happens in the WordPress core file called “admin-ajax.php”, which is what ajaxurl points to.

      2). In order to completely understand this, you will need to understand how processing ajax requests in WordPress works. Take a look at this tutorial I did to see if it clears everything up for you:

  2. Robert Austin


    Thank you for the response. That does help.


    Robert Austin

  3. Jacob Dubail

    Hi Pippin,

    Should you be verifying the nonce in the pwuf_process_new_follow and pwuf_process_unfollow functions?


Error: Please enter a valid email address

Error: Invalid email