Paal Joachim Romdahl (@paaljoachim)

Forum Replies Created

Viewing 1 replies (of 1 total)
  • I added a link to a private forum in the menu so that a logged in user could easily access the forum. Yes I could add a menu for logged in users, but I decided to instead redirect the not logged in users.

    Here is the code I used:

    // Redirect private bbPress forum to specific page.
    add_action('template_redirect', 'private_content_redirect_to_login', 9);
    function private_content_redirect_to_login() {
      global $wp_query,$wpdb;
      if (is_404()) {
        $host = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
        $path = dirname($_SERVER['REQUEST_URI']);
        $forums = "forum";
        $location = "https://direitoshumanosangola.org/not-logged-in/";
        }
        if(strpos( $path, $forums ) !== false){
          wp_safe_redirect($location);
          exit;
      }
    }

    I made a tutorial for it here:
    https://www.easywebdesigntutorials.com/hide-buddypress-pages-and-bbpress-forums-from-not-logged-in-users/

Viewing 1 replies (of 1 total)