Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How to redirect to a custom page url if non logged in user clicks on a profile

@anonymized-18187419

Inactive

Hi kp,

yes I’m with ya on keeping extra plugins to a minimum.

Code published here…

https://easywebdesigntutorials.com/hide-buddypress-pages-and-bbpress-forums-from-not-logged-in-users/

…with minor modification (to remove bbpress check) seems to achieve what you want, as per below:

function ps_guest_redirect() {
     global $bp;
  if ( bp_is_user() ) {
      if(!is_user_logged_in() and !bp_is_register_page() and !bp_is_activation_page()) {
           wp_redirect('https://google.com');
  exit;
      }
  }
}
add_filter( 'get_header','ps_guest_redirect',1);
Skip to toolbar