Role Based Pricing in Membership 2

Hello

I have a membership site which is live and uses the Membership plugin. I've updated the site on a test server to Membership 2 Pro.

I was using this block of code to offer discounts in MarketPress to my members.

function mp_membership_price_discount( $price ){
	// check for existence of Membership plugin
	if ( class_exists( 'M_Membership' ) ) {
		// check if user is logged in
		if ( is_user_logged_in() ){
		// take 10% discount for users on access level with id=5
			if ( current_user_on_level(5) ) {
				return $price * 0.9;
			}
		}
	}
	return $price;
}
add_filter( 'mp_product_price', 'mp_membership_price_discount' );

It's based on this support topic
https://premium.wpmudev.org/forums/topic/how-do-i-offer-separating-pricing-for-premium-members-using-marketpress

I get an undefined function error for current_user_on_level() and I guess if ( class_exists( 'M_Membership' ) ) won't work either.

Can you help, or describe a better way to offer discounts to members?

Thanks
Pete