If visitor not logged in then redirect...

I'm setting up a Buddypress site and looking for the functionality in the title, so that certain pages are restricted if a user is not logged in. Instead they should be redirected to a specific url.

I thought I had found the answer here, but I have tried the code in the post mentioned and I see no change... I can still view pages that should be restricted when I am not logged in.