Title: Code snippet?
Last modified: October 5, 2018

---

# Code snippet?

 *  Resolved [Paal Joachim Romdahl](https://wordpress.org/support/users/paaljoachim/)
 * (@paaljoachim)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/code-snippet-3/)
 * Hey
 * We got a lot of plugins on a site that is multilingual with using WPML and many
   other plugins. I am looking for simple code snippet that I can add to the functions
   file to make the various BuddyPress pages hidden from not logged in users.
 * Thanks.

Viewing 1 replies (of 1 total)

 *  Thread Starter [Paal Joachim Romdahl](https://wordpress.org/support/users/paaljoachim/)
 * (@paaljoachim)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/code-snippet-3/#post-10756750)
 * I also asked in the slack channel for BuddyPress:
    [https://wordpress.slack.com/archives/C02RQBYUG/p1538799273000100?thread_ts=1538777140.000100&cid=C02RQBYUG](https://wordpress.slack.com/archives/C02RQBYUG/p1538799273000100?thread_ts=1538777140.000100&cid=C02RQBYUG)
 * Here is the code snippet for blocking out not logged inn users from reaching 
   BuddyPress pages:
 *     ```
       // Protect BuddyPress pages
       function ps_guest_redirect() {
              global $bp;
           if ( is_buddypress() || bp_is_user() ) {
               if(!is_user_logged_in()) {
                    wp_redirect('URL_TO_PAGE_WHERE_WANT_TO_REDIRECT');
       exit;
               }
           }
       }
   
       add_filter('get_header','ps_guest_redirect',1);
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Code snippet?’ is closed to new replies.

 * ![](https://ps.w.org/lock-my-bp/assets/icon-256x256.gif?rev=1756892)
 * [Wbcom Designs - Private Community for BuddyPress](https://wordpress.org/plugins/lock-my-bp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/lock-my-bp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/lock-my-bp/)
 * [Active Topics](https://wordpress.org/support/plugin/lock-my-bp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/lock-my-bp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/lock-my-bp/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Paal Joachim Romdahl](https://wordpress.org/support/users/paaljoachim/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/code-snippet-3/#post-10756750)
 * Status: resolved