Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create a separate home page for logged in users


  • craig
    Participant

    @craigheyworth

    Hey Guys,

    Ok so I’m looking to create the standard homepage (that explains the benefits of joining the community etc) and then once they join/login, they’re brought to a ‘logged in’ homepage that shows the community in full swing.

    Any initial thoughts on the most optimum way to achieve this considering the reporcussions on SEO etc?

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

  • Henry
    Member

    @henrywright-1

    @craigheyworth

    Any initial thoughts on the most optimum way to achieve this considering the reporcussions on SEO etc?

    Keep in mind the search engine bot will be visiting your site as a ‘logged-out’ site visitor, so it won’t see any of the content you display to logged in users only.

    One approach you could take is to have a different front page set for logged-in and logged-out visitors.

    function custom_front_page() {
        if ( ! is_admin() ) {
            if ( is_user_logged_in() ) {
                $page = get_page_by_title( 'About' );
        	    update_option( 'page_on_front', $page->ID );
        	    update_option( 'show_on_front', 'page' );
    	} else {
       	    $page = get_page_by_title( 'Register' );
        	    update_option( 'page_on_front', $page->ID );
        	    update_option( 'show_on_front', 'page' );
    	}
        }
    }
    add_action( 'init', 'custom_front_page' );

    Where ‘About’ and ‘Register’ are the names of the pages you’d like to use as the front page.


    Vcize
    Participant

    @vcize

    Anyone had any luck with this?

    I tried the solution above from @henrywright-1, but it has its issues.

    The first time you load the home page it is just a blank white page, presumably as the first load only sets the homepage using the logic above. When refreshing, you’re taken to the proper page. However, that actually sets the homepage as that, and anyone after is sent to the same one.

    So, for instance, using the code above…

    User #1 is already logged in and visits the site, they get a blank page.
    User #2 is already logged in and visits the site, they get the (correct) about page.
    User #3 is not logged in and visits the site, they also get the (incorrect) about page.

    If you reverse it and the first person to go to the site is logged out, you get…

    User #1 is not logged in and visits the site, they get a blank page.
    User #2 is not logged in and visits the site, they get the (correct) Register page.
    User #3 is already logged in and visits the site, they also get the (incorrect) Register page.

    Additionally, sometimes when a logged in user visits they randomly get the members page.

    Any working solution for this out there?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Create a separate home page for logged in users’ is closed to new replies.
Skip to toolbar