I'm building a plugin that links WordPress and Salesforce like this (updating here to try to clarify what the plugin does):

  1. salesforce_push: send data from WordPress to Salesforce. This happens when a new item (this could be a post, user, etc. depending on map settings) gets created/updated/deleted in WordPress, and that data is sent to the Salesforce API to create/update/delete the mapped object. Mapping occurs based on the ID of the item (user ID to Contact ID, for example).
  2. salesforce_pull: check Salesforce for created/updated/deleted objects that should come back to WordPress (based on map settings). For example, a Contact gets updated in Salesforce; this should update the corresponding user in WordPress.
  3. There is a table that links object types (user to contact, for example) as well as object rows (a specific user ID to a specific Contact ID, for example).

There are two wp_schedule_event methods: one for push and one for pull. The above methods send data to the events, and then the processing happens (either to call a Salesforce API method, or a WordPress method, to create/update/delete an item).

Currently, this is what happens:

  1. I create/update/delete an item in WordPress (on localhost). The same happens in Salesforce the next time the push wp_schedule_event runs. For example, every 5 minutes it sends new users to Salesforce and create Contacts for them, or updates them if they're already mapped to WordPress users.
  2. I create/update/delete a mapped item in Salesforce. The next time the pull wp_schedule_event runs, it loads the data for that item from the Salesforce API and sends it to salesforce_pull where it will call methods to create/update/delete objects in WordPress (this part isn't completed yet).

The problem is this:

In #1, when a Salesforce item is created or updated based on the WordPress activity (salesforce_push), it also tries to call the salesforce_pull method because it realizes that something has changed in Salesforce.

This creates a loop that won't be satisfied, because each system keeps trying to update the other one. I've been trying to determine what kind of check to run on each method to see if it was just called by the other one, but am so far unable to create one that does not also stop legitimate edits in the system.

An event I'd like to stop would be like this:

  1. WordPress user updates a profile and it gets sent to Salesforce and updates the contact.
  2. Salesforce sends the same change back to WordPress to update the user.

(This is what currently happens, to be clear.)

An event I'd like to allow would be like this:

  1. WordPress user updates a profile and it gets sent to Salesforce and updates the contact.
  2. Salesforce processes a financial transaction for the user and updates their giving history, and sends it back to WordPress.
  • Sorry I read it a few times but could not understand the process. can you try to make your idea a bit more clear. I am unable to really understand the entire process cycle Sep 20, 2016 at 21:24
  • @AhmedElmahdy sure, I tried updating to clarify. Sep 20, 2016 at 21:45
  • So for example: you create a user in WP, the user is mapped to Salesforce WP -> Salesforce API but the problem is the same reversed request happens from salesforce API -> WP for the same user.. did I get it? Sep 20, 2016 at 21:54
  • @AhmedElmahdy Yes, that's right. The updated contact in Salesforce sends its data back to WordPress, because it has "changed." Sep 20, 2016 at 21:57
  • @ialocin would you want to write this as an answer so I could approve it? No worries either way. Sep 23, 2016 at 14:46

1 Answer 1


You should create a user data version index variable, every time it changes increment. This should help keeping track of which the most current version of the data set is. You can use the value of that index to determine, if an update should happen or not.

(Answer from comment)

Your Answer

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

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