You can create a level to access only a single group in BuddyPress?

Hello, I am trying to set up my website so that users have to pay a subscription fee for access to individual groups. This is opposed to paying for a specific membership level that would allow them to enter multiple groups. For example, I have group A, B, and C. Group A charges $10 per week, Group B charges $20 per week, and Group C charges $25 per week . Users will only gain access to the group they subscribe to. I am using buddy press to create the groups. I have followed a thread on the S2 member website that talks about using the custom capabilities to fulfill this action. The thread provides a snippet of code that seems to do what I want my website to do, but I cannot get this code to work. Whenever I put this code in my custom bp plugins folder, it causes the plugin to become invalid. Is there something wrong with the code? The code that I am using is down below.

indent preformatted text by 4 spaces

add_action (“wp”, “my_custom_capabilities”, 1);
function my_custom_capabilities ()
if ( bp_is_groups_component() && ‘group-name’ == bp_current_item() && !current_user_can (“access_s2member_ccap_custom-name”))
exit ();