Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbp Private Group Non-Logged In User Redirect


  • simonbegg
    Participant

    @simonbegg

    Hi,

    I’m having an issue setting up bbp Private Groups to work exactly as required.

    I’ve set up a private forum to be visible only to logged in users (I also have other forums visible to all).
    This works fine in that the forum is invisible to non-logged in users.
    However when a non-logged in user goes directly to the private forum url (eg http://teamtwobees.com/forum/facebook-advertising/) they are presented with a 404 page. I’d like these users to be redirected to a log in page and then redirected back to the private forum after having logged in.

    I’ve set the ‘URL of redirect page for NON-LOGGED-IN’ option but this doesn’t seem to have any affect – users still get the 404 page.

    What is the correct way to achieve what I’m looking for?

    bbPress v 2.5.6
    bbp Private Groups v 2.5.6
    WordPress v 4.1.1

    Thanks

    Simon

Viewing 10 replies - 1 through 10 (of 10 total)

  • Robin W
    Moderator

    @robin-w

    check that you have put the url in correctly – copy from the setting into your browser and check that it works it needs to be the full url


    simonbegg
    Participant

    @simonbegg

    The URL is definitely correct.
    Is what I’m trying to achieve standard functionality?


    Robin W
    Moderator

    @robin-w

    Can you post here what you have put into the setting?


    simonbegg
    Participant

    @simonbegg

    Just trying to redirect to the login page, have tried other URL’s as well.
    http://teamtwobees.com/wp-login.php

    Click to activate forum visibility is ticked.
    Forum visibility is set to ‘Private’

    Thanks
    Simon


    Robin W
    Moderator

    @robin-w

    yes for a private forum with visibility that is the expected behaviour.

    If the forum is private then it is not seen by non-logged in users, so the logic is that as you don’t expect non-logged in users to know that the forum exists, you wouldn’t want them to know that a topic exists, and login would tell them that they url existed, so they get a 404 in all cases.

    Set the forum to public, and the logon screen will appear.


    simonbegg
    Participant

    @simonbegg

    Ok, makes sense. Think I’ve got the hang of it now.
    Thanks for your help,

    Simon


    Robin W
    Moderator

    @robin-w

    Great – glad you’re fixed !


    Paal Joachim Romdahl
    Participant

    @paaljoachim

    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/


    Robin W
    Moderator

    @robin-w

    that’s great – thanks for posting your solution and a tutorial – that will definitely help others 🙂


    meilleurgrossiste
    Participant

    @meilleurgrossiste

    hello,
    Thanks for the tutorial

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar