There is a filter called ll_intercom_custom_data (see line 224) which allows you to filter the $custom array.
So for example if you store the user’s country in the usermeta table, you could add something like this to your functions.php file:
add_filter( 'll_intercom_custom_data', 'my_intercom_custom_data' );
function my_intercom_custom_data( $custom ) {
$user_id = get_current_user_id();
$country = get_user_meta( $user_id, 'country', true );
$custom[] = '"Country":"' . $country . '"';
return $custom;
}
If you’re not familiar with WordPress filters, see this page in the Codex.
The important thing is the format of the elements in the $custom array:
- For strings it should be
"key":"value" (note the two sets of double quotes).
- For integers it should be
"key":value (only one set of quotes).
Just to let you know that in the new version of Intercom for WordPress the ll_intercom_custom_data filter has changed slightly, due to a change in the Intercom API.
It’s now a straightforward array of key/value pairs, there’s no need to insert colons and quotes. Here’s how you should now do the above code:
add_filter( 'll_intercom_custom_data', 'my_intercom_data' );
function my_intercom_data( $custom ) {
$user_id = get_current_user_id();
if ( $country = get_user_meta( $user_id, 'country', true ) ) {
$custom['Country'] = $country;
}
return $custom;
}
Sorry it’s no longer backwards compatible, but I had to make this change to ensure the plugin continues to work in the future.
Simon