Skip to content

Instantly share code, notes, and snippets.

@hlashbrooke
Created August 9, 2013 16:26
Show Gist options
  • Save hlashbrooke/6195020 to your computer and use it in GitHub Desktop.
Save hlashbrooke/6195020 to your computer and use it in GitHub Desktop.
Segment.io WordPress plugin: Adding filter to identification traits
<?php
$identify = array(
'user_id' => $user->user_email,
'traits' => apply_filters( 'segment_identify_traits', array(
'username' => $user->user_login,
'email' => $user->user_email,
'name' => $user->display_name,
'firstName' => $user->user_firstname,
'lastName' => $user->user_lastname,
'url' => $user->user_url
) )
);
?>
@baseoon
Copy link

baseoon commented Apr 27, 2016

Hi Hlashbrooke, we found this through wordpress.org site. Segment has added your requested filter, but we can't seem to make it work.
We added the add_filter to the functions.php and told the filter to return our traits. but somehow we can't get it to work. can you enlighten us how you got your custom filter to work? just for testing we added our own filter to analytics-wordpress.php and add_filter to function.. still nothing happends.

This is the filter we used:

add_filter( 'segment_get_current_user_identify', 'oshare_id' ); function oshare_id() { $identify = array( 'user_id' => $user->user_email, 'traits' => array( 'voornaam' => $voornaam = xprofile_get_field_data( 'Voornaam', bp_loggedin_user_id(), $multi_format = 'comma' ), 'achternaam' => $achternaam = xprofile_get_field_data( 'Achternaam', bp_loggedin_user_id(), $multi_format = 'comma' ), 'werkgever' => $werkgever = xprofile_get_field_data( 'Werkgever', bp_loggedin_user_id(), $multi_format = 'comma' ), 'indienst' => $indienst = xprofile_get_field_data( 'Indienst datum', bp_loggedin_user_id(), $multi_format = 'comma' ), 'uitdienst' => $uitdienst = xprofile_get_field_data( 'Uit dienst datum', bp_loggedin_user_id(), $multi_format = 'comma' )));return $identify; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment