Check on the user group membership in joomla:

	/*
	* Function 
	*/
function getAccess($groups=array(), $user_id=0)
	{
		if ($user_id == 0) $user_id = JFactory::getUser()->id;
		echo $user_id;
		if (count($groups) == 0 || $user_id == 0) return false;
		return (count(array_intersect(JFactory::getUser($user_id)->getAuthorisedGroups(), $groups))>0);
	}

// Print groups user id 
	print_r($user_id = $user->getAuthorisedGroups());

// Output Group Access Permissions
    $groups = array(18, 8);// an array of groups separated by commas
	
    if(getAccess( $groups)) echo 'Access granted to groups 18 and 8';