How we integrated Salesforce with WordPress for ILPA

Author - Vic Lobins

Posted By Vic Lobins Lead Back End Developer

Date posted 16th Apr 2021

Category Marketing, WordPress

Array

About ILPA and the website project

The Immigration Law Practitioner’s Association (ILPA) approached 93digital looking for a website redesign and development to improve UX for current ILPA members and attract new ones. As an organisation, ILPA relies on Salesforce to manage their business and to provide a holistic view of their key customers and members.

ILPA is a professional association and registered charity, the majority of whose members are barristers, solicitors, advocates and OISC regulated advisers practising in all aspects of immigration, asylum and nationality law founded in 1984.

You can learn more about the ILPA project here.

Why is a Salesforce and WordPress integration important?

In addition to improving UX and supporting ILPA’s marketing activities to attract new members, a key outcome of the website project was to ensure successful integration of the Salesforce API with their new WordPress site.

In a nutshell, Salesforce provides a customer relationship management (CRM) system that helps manage customer data. Salesforce CRM gives its clients a holistic view of their customers, ensuring customer details are up to date, customer interactions are tracked and clients can easily manage customer accounts.

By integrating customer data from Salesforce and data from their WordPress website, ILPA are able to build an even more comprehensive picture of their customers and members, allowing ILPA to support their needs better. In addition, ILPA use Salesforce for their event management, so it was important that the booking and payments systems were also taken into consideration.

What follows is an outline of the key aspects of Salesforce and WordPress interaction for this project from the view point of a WordPress developer. We provide an outline of each aspect of the integration, followed by a clear, step-by-step of how this works ‘behind the scenes’ for the techy-marketer.

How we integrated Salesforce and WordPress

The three key aspects of this integration were: a Members Directory, a custom user flow, and event bookings. This was a custom built integration utilising the PHP cURL library and Salesforce Object Query Language (SOQL) to authenticate and connect to the ILPA Salesforce instance, as well as fetch and create data records. Below you will find an outline of each of the three key aspects of integration alongside an outline of the approach we took.

Members Directory

ILPA has around 300 member organisations registered with them so they needed an index page to list all of these members and an individual page for each to display their details.

The listing page can be found here: https://ilpa.org.uk/members-directory/ and you can click ‘More Information’ to see each member’s individual page. There are also filters on the listing page to aid with searching the directory.

The Approach

This was relatively simple as all we needed to do is connect to the Salesforce instance and use cURL along with SOQL to pull the required fields from a custom Salesforce object. However, performing this request on every page load would very quickly overtax the API and exceed the request limit. In order to avoid that we had to implement a cron job and save all the required data to a cache file on the server.

A cron job can be thought of as a scheduler utility and it runs a predefined job or function periodically, in this instance it connects to the API and pulls the Members Directory data, then saves it to a PHP file on the server. It does this every two hours. When the Members Directory pages are loaded they simply fetch the saved PHP file containing all the data and render it on the front end.

Custom User Flow

Another requirement for this project was a custom user flow. This allowed any existing users in the ILPA Salesforce platform to login and view or change their account details. Furthermore, there had to be functionality for new users, who also need to be able to register and have their details sent across to Salesforce.

The Approach

The first challenge was to make sure that all existing users can log into the new site, to do this we created a custom login interface powered by AJAX. The AJAX scripts capture the login data and securely send it to an internal PHP script, which then connects to Salesforce and does a quick check to verify that the user exists (and their membership is current). Once verified, the relevant user data is pulled and saved in the WordPress database creating a new user.

We needed to make sure there was bidirectional communication between WordPress and Salesforce. This means the API would need to be called every time a user logs in to verify them and make sure the user data is synced to WordPress. Once logged in they would be able to browse and view their account data and event bookings without further API calls. That is until they change any of their details in their account page (ie: email address, password, etc.), at this point, as well as saving the data in WordPress we need to call the API and update their records in Salesforce.

The Registration and Password Reset features use the same functionality. Any new registrants would enter their details into a custom form which is then saved to WordPress and pushed to Salesforce. Any attempts to reset a forgotten password would first be verified against a last name and email address in Salesforce, this would then trigger an email from WordPress with a password reset link, once the password is reset it again gets saved in WordPress and pushed to Salesforce for that user.

Events

ILPA also uses Salesforce to create and manage events, this includes event details such as descriptions, speakers, prices, dates, locations, attendees, payments, and more. For this we needed to pull the events from Salesforce, create a calendar view and facilitate the booking of these events.

Events page can be found here.

The Approach

We needed to create functionality to pull any live events from Salesforce into WordPress. Rather than starting completely from scratch we used The Events Calendar plugin, which sets up an Events post type and allows us to create a calendar view and a single events page. Using Advanced Custom Fields we also added some extra metadata we needed to display for each event. Once this was set up we added another cron job to run every two hours, only this time instead of saving data to a cache file, the cron job saved it into the custom Events post type.

Furthermore, we had to allow the users to book and pay for tickets to these events. As there were more moving parts to this, the process was a lot more intricate to accommodate for the interactions between custom Salesforce objects and another custom post type that was set up to contain the booking data. There are three parts to this process:

  1. User clicks ‘Book Now’ on the selected event:
    • Custom form gathers all the required data relating to the event and the user making the booking, and sends it securely via AJAX to an internal PHP script.
    • The PHP script creates a new Event Booking post with the status of ‘Pending Payment’ and saves all the required data there.
    • The post is assigned a ‘custom’ value and the user is redirected to the PayPal payment page along with that value as a parameter.
  2. User completes PayPal payment:
    • PayPal saves the ‘custom’ value along with the transaction ID.
    • PayPal redirects the user back to the ILPA site with a parameter of the transaction ID.
    • Fire up the PayPal API and verify the sale using the transaction ID.
      To authenticate and connect to the ILPA PayPal instance we used the PayPal PHP SDK. Once verified, the API returns our ‘custom’ value.
  3. Confirmation:
    • Using the returned ‘custom’ value we fetch the post saved in step 1 and all its metadata.
    • Connect to the Salesforce API and push the new booking along with its data.
    • Change Event Booking post status to ‘Booked’ and save the transaction ID along with some returned Salesforce data relating to the booking.
    • Show confirmation message (or relevant error message if any of the above steps failed).

If all of these steps are successful we will now have a new Event Booking record in Salesforce along with who booked it, the PayPal transaction ID and Opportunity/Event records which are used by ILPA for internal administration.

What’s more is that we also have a complete record of this in WordPress:

Let's Talk

Do you have a web design and build project coming up that you would like to talk about?