Displaying CRM Data in WordPress

Overview

With WP Fusion it’s possible to display data from your CRM in WordPress, allowing you to personalize your site for logged-in users using data from their CRM contact record.

For example:

Welcome back, your next exam date is 9/9/2020.

Or

Your assigned advisor is Jim Jones, your learning style is Auditory.

Shortcodes

Using WP Fusion’s user_meta shortcode, you can display any data in your site’s database for the current user.

You can see all the available meta field keys on the Contact Fields list in the WP Fusion settings.

The keys in the Meta Field column can be used to display a user’s data without any extra steps. For example to display the current user’s first name, the shortcode would be

[user_meta field="first_name"]

However, you may have data that only exists in your CRM, not in WordPress. To display that data, you’ll first have to create a place to store the data in WordPress, and then use WP Fusion to load the data from your CRM.

Note: While it might sound more convenient to load the data from your CRM every time the page is displayed, this actually can introduce performance problems if you have a lot of users on your site, since an API call needs to be made on every page load. For that reason it’s better to use WP Fusion to load the data into WordPress first, where it can be displayed without requiring an external API call.

Managing Custom Fields

Before WP Fusion can load a custom field from your CRM, it needs a place to store the data on your site. For an overview on how data is synced between WordPress and your CRM, see the Syncing Contact Fields documentation.

An easy way to create a new field is to use a plugin that lets you manage custom fields for users, such as User Meta Pro, or Advanced Custom Fields. Or if you’re using a membership plugin like BuddyPress or MemberPress, these plugins have options for managing profile fields.

Once you’ve created a field to store your custom data, locate it on the Contact Fields list in the WP Fusion settings, and select a corresponding field in your CRM to enable the field for sync.

In this case, we’ve used User Meta Pro to create a field with key new_user_meta_field, and linked it to the Test Custom Field Two field in ActiveCampaign.

Loading the Data

Now that you have the custom field created and linked with the corresponding CRM field, you need to load the data into WordPress. There are a few ways to do this:

  • Pull User Meta: From the Advanced tab in the WP Fusion settings you can run a Pull User Meta operation, which will load any enabled fields from your CRM into WordPress for all your users. More info on that here.
  • Webhooks: If you’re updating the custom field in your CRM over time, you can create an automation that sends a webhook back to WP Fusion when a contact has been modified, using the ?wpf_action=update method. This will load the updated values for that specific contact, and they can be displayed in WordPress. More info on webhooks here.
  • Shortcode: The [wpf_update_meta] shortcode can also be used to refresh the current user’s stored metadata from their CRM contact record when a page is viewed. To use the shortcode, put it above any [user_meta] shortcodes on the page so the data has been loaded by the time those shortcodes are executed. Note that the [wpf_update_meta] shortcode will slow down the page load by a few seconds, so it’s recommended to use it sparingly.

Testing

Whichever method you use to load the data, the WP Fusion logs will show the data being loaded from your CRM into the user’s metadata in WordPress.

In this case, the new_user_meta_field we created earlier has loaded a value of http://test.com from ActiveCampaign.

Now if we use the [user_meta] shortcode, that value can be output on a page. For example

Your personalized results can be found at [user_meta field="first_name"]

Would be output as

Your personalized results can be found at http://test.com.

Was this helpful?