Support » Plugin: Intercom for WordPress » Custom Data

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Simon Blackbourn


    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).
    Plugin Author Simon Blackbourn


    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.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Data’ is closed to new replies.