Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Hide Homepage (9 posts)

Started 10 months, 3 weeks ago by: asdfgh

  • Profile picture of asdfgh asdfgh said 10 months, 3 weeks ago:

    Hey, I’ve searched everywhere for this and I’ve came up with nothing… I was wondering whether there was a way to hide the home page for a logged out users? I’ve tried a bunch of plugins, and none of them have options for it… is there any code? Or is there a way to create a redirect so when logged out users visit the home page, it takes them to a different page of my choice? Thanks in advance :)

  • Profile picture of asdfgh asdfgh said 10 months, 3 weeks ago:

    Anyone at all… It’s been three days, and I really need this :|

  • Profile picture of Brajesh Singh Brajesh Singh said 10 months, 3 weeks ago:

    put this in your bp-custom.php and change the redirect page url properly.

    add_action("template_redirect","my_redirect");
    function my_redirect(){
    
        if( !is_user_logged_in()&&is_front_page()){
    
            wp_safe_redirect(get_bloginfo('wpurl')."/about");
            exit(0);
        }
    }

    That should work.

  • Profile picture of asdfgh asdfgh said 10 months, 3 weeks ago:

    Thank you so much! Where do I put the URL I want to redirect to?

  • Profile picture of asdfgh asdfgh said 10 months, 3 weeks ago:

    @Brajesh Singh it adds a visible strip of code to the top of the website, I don’t know whether that’s because I haven’t found where to put the url in or not?

  • Profile picture of pcwriter pcwriter said 10 months, 3 weeks ago:

    @yoursocialbox

    Seeing code at the top of a page is usually a result of improperly formatted opening/closing tags. Here are some things to check in your bp-custom.php:
    - Make sure you’ve copied the code exactly as in the post above.
    - Check the double-quotes; make sure they are straight quotes ( ” ) not curly ones.
    - Be sure your bp-custom.php file content begins and ends with the proper tags: an opening <?php tag at the very top, and a closing ?> tag at the very bottom.

    The part of the code where you put your own URL is where you see "/about". Change that to the page slug you want to redirect to (the page slug is what comes after your domain name). For example, if you want to redirect to http://example.com/my-redirect, change it to "/my-redirect".

    Hope this helps! :-)

  • Profile picture of pcwriter pcwriter said 10 months, 3 weeks ago:

    Watch out! I goofed in the post above: I forgot to enclose the quotes in backticks so they display properly.

    Your double-quotes should look like this: "
    NOT this: “

  • Profile picture of asdfgh asdfgh said 10 months, 3 weeks ago:

    Thank you! I done all of that and it is now working perfect! :)

  • Profile picture of pcwriter pcwriter said 10 months, 3 weeks ago:

    :-)