Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide Homepage


  • asdfgh
    Member

    @yoursocialbox

    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 :)

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

  • asdfgh
    Member

    @yoursocialbox

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


    Brajesh Singh
    Participant

    @sbrajesh

    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.


    asdfgh
    Member

    @yoursocialbox

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


    asdfgh
    Member

    @yoursocialbox

    @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?


    pcwriter
    Participant

    @pcwriter

    @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 “ 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! :-)


    pcwriter
    Participant

    @pcwriter

    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: “


    asdfgh
    Member

    @yoursocialbox

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


    pcwriter
    Participant

    @pcwriter

    :-)

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Hide Homepage’ is closed to new replies.
Skip to toolbar