How to add BuddyPress Group IDs to the body class?

I'm trying to add BuddyPress group ID's to the <body> class using the function below (in my theme's functions.php file), but she's-a-no-work.

I need to do some custom css to a few groups in specific, so having the group ID in the body class would be very helpful.

You can see I've tried a few methods to capture the group ID, but non has worked. What am I doing wrong here?

/* add group number to body class  */
global $bp;
//$groupnum = groups_get_group( array( 'group_id' => $group_id ) );
//$groupnum = bp_group_id();
//$groupnum = $bp->group->id;
$groupnum = bp_get_group_id();

function add_bp_group_number_class($classes) {

if ( $groupnum==14 ):
// add 'group-#' to the $classes array
$classes[] = 'group-14';
// return the $classes array
return $classes;

else :
    // do nothing
    $classes[] = '';
    // return the $classes array
    return $classes;