Site icon Google Maps Widget

Salesforce to WordPress Display: Step-by-Step Integration

Customer Relationship Management (CRM) systems like Salesforce are essential for managing data and automating business processes. WordPress, on the other hand, powers a large percentage of the web with its intuitive interface and endless extensibility. What happens when you need to display dynamic Salesforce data directly on your WordPress site? The solution lies in seamless integration—and the good news is, it’s entirely possible. In this article, we will walk you through a step-by-step guide on how to integrate Salesforce with WordPress to effectively display your CRM data.

Why Integrate Salesforce with WordPress?

Before we get into the steps, it’s important to understand why you would want to integrate Salesforce with your WordPress site. Here are some common use cases:

This level of integration can greatly enhance user experience, data access, and business operations.

Overview of Integration Methods

There are several approaches to integrating Salesforce with WordPress, depending on your goals and technical skill level:

  1. REST API Integration: Ideal for custom development and real-time data fetching.
  2. Using paid plugins: Simplifies integration with point-and-click functionality.
  3. Zapier or Middleware: Best for non-developers with basic automation needs.
  4. Web-to-Lead forms: Easy method for pushing data from WordPress to Salesforce.

For displaying Salesforce data directly on a WordPress site, the REST API method is one of the most efficient and customizable options. Let’s walk through how to set it up step by step.

Step 1: Create a Connected App in Salesforce

To securely access Salesforce data, you need to create a connected app that provides API credentials.

  1. Log in to your Salesforce account.
  2. Go to Setup > App Manager and click New Connected App.
  3. Enter details like the app name, email, and API name.
  4. Under API (Enable OAuth Settings), check Enable OAuth Settings.
  5. Set the callback URL (can be https://your-wordpress-site.com/callback) and select OAuth scopes like:
    • Access and manage your data (api)
    • Perform requests on your behalf (refresh_token, offline_access)
  6. Save and wait for the new app to be activated (can take 10–15 minutes).

Once activated, make a note of your Consumer Key and Consumer Secret—you’ll need them to authenticate API calls.

Step 2: Set Up Authentication with Salesforce

Salesforce requires OAuth 2.0 authentication to access data through its REST API. You can use a plugin or custom code to handle token retrieval.

If you’re using PHP, here’s a basic example to get an access token:


$token_url = "https://login.salesforce.com/services/oauth2/token";
$data = [
  'grant_type' => 'password',
  'client_id' => 'YOUR_CLIENT_ID',
  'client_secret' => 'YOUR_CLIENT_SECRET',
  'username' => 'YOUR_SALESFORCE_USERNAME',
  'password' => 'YOUR_PASSWORD' // append security token if needed
];

$response = wp_remote_post($token_url, [
  'body' => $data
]);

$body = json_decode(wp_remote_retrieve_body($response), true);
$access_token = $body['access_token'];
$instance_url = $body['instance_url'];

Securely store this information for subsequent API calls.

Step 3: Fetch Data from Salesforce

With an access token in hand, you can now query Salesforce data using the REST API. For example, to fetch a list of leads:


$endpoint = $instance_url . "/services/data/v52.0/query?q=" . urlencode("SELECT Name, Company, Email FROM Lead LIMIT 10");

$response = wp_remote_get($endpoint, [
  'headers' => [
    'Authorization' => "Bearer $access_token",
    'Content-Type' => 'application/json'
  ]
]);

$leads = json_decode(wp_remote_retrieve_body($response), true);

This will retrieve a JSON dataset of Salesforce leads which you can then display on your WordPress page or post.

Step 4: Display Data on WordPress

Depending on how your site is built, you could use shortcodes, custom templates, or even a page builder to display the Salesforce data. Here’s a simple shortcode example:


function display_salesforce_leads() {
  // Assuming you've already fetched leads as an array called $leads
  $output = '<ul>';
  foreach ($leads['records'] as $lead) {
    $output .= '<li><strong>' . $lead['Name'] . '</strong> - ' . $lead['Company'] . ' (' . $lead['Email'] . ')</li>';
  }
  $output .= '</ul>';
  return $output;
}
add_shortcode('salesforce_leads', 'display_salesforce_leads');

Add the shortcode [salesforce_leads] to any WordPress post or page, and the data will render on the frontend dynamically.

Step 5: Automate API Refresh Tokens

Remember, Salesforce access tokens expire quickly. To maintain a seamless user experience, set up a cron job or WordPress scheduled event to automatically refresh your token at regular intervals using the stored refresh token.

If you’re using a serverless function or external API handler, you may also choose to cache the token temporarily using a transient or database table in WordPress.

Alternative: Use Salesforce-WordPress Plugins

If you’re looking for a less technical route, several plugins can simplify the process:

While these tools excel in pushing data from WordPress into Salesforce, displaying Salesforce data on WordPress is still best handled via custom API integration or specialized services.

Security Considerations

When working with sensitive customer data, security must be a priority. Here are a few best practices:

Always audit token storage and role-based access to restrict unauthorized usage.

Final Thoughts

Integrating Salesforce with WordPress opens up a world of possibilities—from pipeline transparency to better lead management and customer service. Whether you’re a developer looking to build a custom API integration or a business owner exploring plugins, there’s a route for every level of expertise and need.

With the right tools and configurations, your WordPress site can become an interactive dashboard that displays live Salesforce data, driving stronger engagement and smarter decisions.

Embrace this dynamic integration and elevate your digital ecosystem to new heights!

Exit mobile version