Hide profile group from Public

Ask wrote some code to help me with this, it's here:

https://gist.github.com/bappi-d-great/7ad5c24e56240da65545

But I can't get get the paid membership version to display bp profiles to the public. I noticed on the free version of the plugin this wasn't a problem. Ask, can you please have a look at the code and see will it work on the free version? There was an error on this line when I tried : $factory = Membership_Plugin::factory();

Thanks