Support » Plugin: BuddyPress Registration Options » Redirect to Front Page if not logged in – can that be changed?

  • Resolved msteidl

    (@msteidl)


    In case a user is not logged in and try to access BuddyPress areas, he’s automatically redirected to the frontpage without any hint that he just might need to log in.

    Is there any chance to redirect users to a certain page where I might get this info on?

    Regards
    Michaela

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Michael Beckwith

    (@tw2113)

    Good day @msteidl

    We do, but it’s not a setting that we have any built in UI for. If you’re familiar with WordPress filters though, you should have no issue. We have the following filter available.

    /**
     * Filters the URL to redirect to for logged out users.
     *
     * @since 4.3.0
     *
     * @param string $value URL to redirect to.
     */
    $logged_out_url = apply_filters( 'bprwg_logged_out_redirect_url', get_bloginfo( 'url' ) );
    

    You could change this with something like the following, in your functions.php file:

    function msteidl_bpro_logged_out_redirect( $original ) {
        return 'http://www.example.com/redirect-explaination';
    }
    add_filter( 'bprwg_logged_out_redirect_url', 'msteidl_bpro_logged_out_redirect' );
    

    Thanks for the quick reply.

    Unfortunately, this did not work.

    This is what I have in my functions.php:

    /**
    * Filters the URL to redirect to for logged out users.
    *
    * @since 4.3.0
    *
    * @param string $value URL to redirect to.
    */

    $logged_out_url = apply_filters( ‘bprwg_logged_out_redirect_url’, get_bloginfo( ‘url’ ) );

    function wp_b_bpro_logged_out_redirect( $original ) {
    return ‘https://uh-karlsruhe.de/members-only’;
    }
    add_filter( ‘bprwg_logged_out_redirect_url’, ‘wp_b_bpro_logged_out_redirect’ );

    But unfortunately Members who are not logged in are still redirected to Frontpage.
    Where’s my mistake?

    Regards
    Michaela

    Plugin Author Michael Beckwith

    (@tw2113)

    From everything I can see, you have no error. However, a detail that did slip by my memory, is that these redirects are only for if you have the “private network” option enabled. If you want to allow people to browse, but not able to interact, then the redirect isn’t considered. Can you confirm that setting is in place?

    Hi Michael,

    these are the settings in my account:
    https://www.dropbox.com/s/j9udr8v11llko5q/Screenshot%202018-02-01%2016.31.01.png?dl=0

    As you can see, private network is enabled, unfortunately, redirect does not work anyhow.

    Any idea what I can do to get this changed?

    Regards
    Michaela

    Plugin Author Michael Beckwith

    (@tw2113)

    Hmm.

    For what it’s worth, this is the only part you need to be adding to the functions.php file.

    function wp_b_bpro_logged_out_redirect( $original ) {
        return 'https://uh-karlsruhe.de/members-only';
    }
    add_filter( 'bprwg_logged_out_redirect_url', 'wp_b_bpro_logged_out_redirect' );
    

    It’s also what I used when testing yesterday and it was working. I am curious if the extra part I am assuming you had with the apply filters line was throwing things off somehow.

    Other than that, it should be working.

    Tried this – but unfortunately it still does not work.

    This is my custom function:

    https://www.dropbox.com/s/8nrdee4uejulkis/Screenshot%202018-02-01%2017.06.03.png?dl=0

    And one page that should redirect to /members-only is:
    http://uh-karlsruhe.de/pinnwand.

    As you can see, it still redirects to Frontpage.

    Plugin Author Michael Beckwith

    (@tw2113)

    At this point, I am really not sure why it’s not working for you, truth be told. Everything checks out from what I can see, and when I tried with my own local install it worked fine. Only thing I can think of at the moment is that the code above isn’t getting loaded at all. Looking at the screenshot you just provided, it seems like the “On/Off” switch is in the off position. Perhaps click on the “on” side and try again.

    OMG … sometimes it’s just this simple.

    Thanks for you patience – it actually was not working due to the Switch on “Off” :-/

    Regards
    Michaela

    Plugin Author Michael Beckwith

    (@tw2113)

    You’re welcome.

    That type of on/off switch I have a love/hate thought about. I love the idea of being able to disable while retaining the contents of the setting. However I hate it as well because people more or less expect these types of spots to just work.

    Glad we were able to figure it out in the end. Have a good rest of your week 😀

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