Excellent. In that case, the following code snippet will adjust the SQL query myCRED runs to get the leaderboard to only include users who are members of the current blog:
add_filter( 'mycred_ranking_sql', 'mycred_pro_mu_leaderboard', 10, 2 );
function mycred_pro_mu_leaderboard( $query, $args ) {
// Do not apply if this is not a multisite
if ( ! is_multisite() ) return $query;
// Apply defaults
if ( ! isset( $args['based_on'] ) )
$args['based_on'] = 'balance';
// Only applicable for leaderboards based on balance
if ( $args['based_on'] != 'balance' ) return $query;
global $wpdb;
// Limit query to users who are members of this blog
$new_string = $wpdb->prepare( "
INNER JOIN {$wpdb->usermeta} cap
ON ( u.ID = cap.user_id AND cap.meta_key = %s )
WHERE um.meta_key", $wpdb->get_blog_prefix( $GLOBALS['blog_id'] ) . 'capabilities' );
$query = str_replace( 'WHERE um.meta_key', $new_string, $query );
return $query;
}
The above code goes into your theme’s functions.php file and no special adjustments is needed for the mycred_leaderboard.
I will probably include this in myCRED 1.6.