WordPress and buddypress programming

Redirect non logged-in users to registration page if they visit a profile page o

Viewing 0 reply threads
  • Author
    Posts
    • #3847
      Michael Mc
      Keymaster
      @mkmcst
      /*** Redirect non logged-in users to registration page if they visit a profile page or a group page other than the groups directory ***/
      function gwangi_bp_logged_out_page_template_redirect()
      {
          if( ! is_user_logged_in() && ( bp_is_user() || bp_is_group() ) ) {
              wp_redirect( home_url( '/register/' ) );
              exit();
          }
      }
      add_action( 'template_redirect', 'gwangi_bp_logged_out_page_template_redirect' );
Viewing 0 reply threads
  • You must be logged in to reply to this topic.