This topic has 15 replies, 6 voices, and was last updated 9 years by Abe.

  • Author
  • #34950
     briceemry
    Participant

    Hello. I would like to redirect unregistered users to the registration page when they try to access on all buddpress / bbpress pages. I would like to use no plugin for that.
    Thanks!

    #35111
     Abe
    Keymaster

    Hi,
    I came up with this code for you to redirect all users on bbpress and buddypress pages to registration page

    COPY CODE
    
    /**
     * Redirect buddypress and bbpress pages to registration page
     */
    function kleo_page_template_redirect()
    {
        //if not logged in and on a bp page except registration or activation
        if( ! is_user_logged_in() &&
            ( ( ! bp_is_blog_page() && ! bp_is_activation_page() && ! bp_is_register_page() ) || is_bbpress() )
        )
        {
            wp_redirect( home_url( '/register/' ) );
            exit();
        }
    }
    add_action( 'template_redirect', 'kleo_page_template_redirect' );
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #39082
     briceemry
    Participant

    Thank you, it works as I want!
    By cons, is it possible to redirect the user to the current page after login / registration?

    #39083
     bujangga
    Participant

    Hey, why me buddypress error. I use member mansorry and user can’t open images media for their activity . Sory i can’t speak english well.
    Thanks you, regards

    #39233
     Abe
    Keymaster

    For the login see Peter’s redirect plugin @briceemry

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #39234
     Abe
    Keymaster

    @bujangga in rtmedia settings try to enable the media popup

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #39675
     mlennox10
    Participant

    Hi Abe, thanks for redirecting me to this page. Could you let me know where I need to place this code? Should it be on each page I wish to block? I would like to block members page, forum, and activity stream.

    Thanks!

    #39676
     sharmstr
    Moderator

    @mlenox10. It goes in your kleo-child/functions.php file. You need to be running kleo child as well.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #40038
     mlennox10
    Participant

    Hi Sharmstr,

    Thanks for replying. I have just realised that I was redirected here from another discussion but this solution will block all pages. I would just like to block Forum, Activity and Members. Do you have any idea how this can be done? It seems like a common problem but a lot of the plugins people have suggested are outdated and the link doesn’t work.

    Any help would be much appreciated.

    #44625
     sante13
    Participant

    I pasted your code into the kleo-child/functions.php file and it does not work.

    Any ideas?

    Thank you.

    #44626
     sante13
    Participant

    Please disregard my previous post as the code works to the extent that it blocks individual forum posts. I would like to block the entire “FORUM LIST”. Is that possible?

    #45122
     Abe
    Keymaster

    I think it should block forum root too

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #51152
     briceemry
    Participant
    This reply has been set as private.
    #51188
     Abe
    Keymaster

    Try to have Buddypress active if you are using buddypress functions

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #51325
     briceemry
    Participant

    Hello. In reality, what happens is that RevSlider not working normally. It works when I connected, and when I log off, it no longer works. but when I remove the redirect code there, everything works normally.

    #52263
     Abe
    Keymaster

    That makes no sense 🙂 if you get redirected then how can you see the page?? just asking…

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

Viewing 16 posts - 1 through 16 (of 16 total)

The topic ‘Buddypress/bbpress redirection’ is closed to new replies.

Log in with your credentials

Forgot your details?