Created
May 5, 2021 04:05
-
-
Save chavesm/0c844b34f685186927852972743f12eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Don't copy this line if adding this gist to a functions.php file. | |
function get_mepr_id() { | |
if ( !class_exists('MeprUtils') ) { | |
return 0; | |
} | |
$mepr_user = MeprUtils::get_currentuserinfo(); | |
if ( $mepr_user === false ) { | |
return 0; | |
} | |
$active_subscriptions = $mepr_user->active_product_subscriptions('ids'); | |
if ( empty($active_subscriptions) ) { | |
return 0; | |
} | |
return $active_subscriptions[0]; // Returns the first found Active Membership ID | |
} // function() | |
add_filter('monsterinsights_frontend_tracking_options_persistent_gtag_before_pageview', | |
function($options) { | |
// Set the custom dimension | |
$options['dimension9'] = get_mepr_id(); | |
return $options; | |
}, | |
20 // priority | |
); // add_filter() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment