How to make sitewide activity the homepage for all logged in users?

Pretty much what it says on the tin really. Do you lovely folks know how I could make the sitewide activity replace the homepage for all logged in users?

Obviously, logged out users and visitors would need to see the regular homepage complete with call to action etc.

Thanks! :slight_smile:

Dave

  • Mason
    • DEV MAN’s Sidekick

    I like Joe's solution here cause it's nice and neat.

    The other way to do it would be to have a custom header.php for your home page which would filter is_user_loggedin() and direct them to the site activity page if they are logged in, else take them to the regular home page.

    Thanks!

  • davejmason
    • Site Builder, Child of Zeus

    Hi chaps, I like the simplicity of your idea Joe but I would like to have users who click or visit the homepage always see the activity page instead. I like the look of this plugin though so I will probably end up using that also!

    I think James' solution would be the one for my site but I'm not so sure how to go about implementing it. Please could you advise?

    Thanks :slight_smile:

    D

  • aecnu
    • WP Unicorn

    Greetings Dave,

    lol ... but that is not what you said.

    How to make sitewide activity the homepage for all logged in users?

    Pretty much what it says on the tin really. Do you lovely folks know how I could make the sitewide activity replace the homepage for all logged in users?

    Obviously, logged out users and visitors would need to see the regular homepage complete with call to action etc.

    I appreciate your additional feedback but I am quoting you above and in your last post you directly contradict what you originally said.

    I would like to have users who click or visit the homepage always see the activity page instead.

    Now which is it please? All visitors and logged in folks to see the activity page?

    Please advise.

    Cheers, Joe

  • Mason
    • DEV MAN’s Sidekick

    I can give a basic outline, but the way you implement this would vary depending on your theme and exactly how much you want to show to visitors vs. logged in users.

    However, the basic functions required are as follows though:

    <?php if ( is_user_logged_in() ) : ?>
    <?php get_template_part( 'sitewide-activity' ); ?>
    <?php else : ?>
    <?php endif; ?>
    Regular homepage bits continue here

    If you want the header and/or footer to be the same then these functions can go in between the calls to get_header and get_footer on the page template.

    You'd then need to create a sitewide-activity.php template where you would insert whatever you're using for sitewide activity (not sure if this is a buddypress site or something else).

    If the code's simple enough, calling it in a separate file may be unnecessary. I only did that to keep things neat in the original home page template.

    Hope this helps.

  • davejmason
    • Site Builder, Child of Zeus

    Hi Joe, sorry please excuse my explanation. I need LOGGED IN users to see the activity page instead of the homepage and users who aren't logged in to see the regular homepage.

    The homepage will be a simple call to action to get users to register. Logged in users would have no need to see this. Similar to how the facebook homepage for logged in users is the activity feed/wall and logged out users are prompted to register.

    Thanks James, I'll try that solution and report back :slight_smile:

    D

  • aecnu
    • WP Unicorn

    Greetings Dave,

    No problem whatsoever sir.

    Mason James and I had discussed this very ticket last night as we are both working it and he pointed out to me that you were just trying to clarify what you wanted though I understood it differently and by your last post directly above you were doing just that. My bad.

    We look forward to hearing about your results and if you have indeed achieved the effect that you want.

    Please advise.

    Cheers, Joe

  • davejmason
    • Site Builder, Child of Zeus

    Hi Joe, that's okay. I'm always grateful for the awesome support you guys offer. I think you guys and Woo probably offer the most unparalleled support of any service I've ever subscribed to.

    As for the issue, your solution is putting me on the right tracks James so thanks very much for that. I've managed to display the activity feed instead of the regular homepage to logged in users. The layout is a little different to the regular activity feed though. Any ideas why? Is this one for the theme developer?

    http://www.drummersdatabase.com/activity

    Thanks again.

  • Mason
    • DEV MAN’s Sidekick

    Hiya Dave,

    As this is a theme I'm not familiar with it's hard to say what needs to change. If you did a call to template part and loaded the same activity stuff that the theme is using by default, then it should look very similar.

    If not the theme vendor would probably the quickest source for what to do differently. If you can't get it I can make some guest credentials for the site and have a look. No promises, but we'll see what can be done :slight_smile:

    Regardless, let us know how it goes. Thanks!

  • Mason
    • DEV MAN’s Sidekick

    Hiya @davejmason,

    You can shoot messages to my attention (with a link to this thread for reference) through our contact form here:
    https://premium.wpmudev.org/contact/

    I'm happy to look around a bit, but the theme vendor is the best option and we'd consider this something outside our area of normal support.

    Of course, this is also a site for drummers, and who doesn't want to see that up and running correctly? :wink:

    Thanks!

  • davejmason
    • Site Builder, Child of Zeus

    Hi Mason,

    That's a very kind offer considering 3rd party themes are outside your area of support. I have contacted the theme developer and will try this route for now as you have already been incredibly helpful! :slight_smile:

    Thanks again folks

  • davejmason
    • Site Builder, Child of Zeus

    Ok all sorted! I conctacted the theme developer and they suggested adding this to the functions.php

    I thought I'd repost here in case this question pops up for anybody else :slight_smile:

    /* ------------------------------------------------
         Redirect logged in users to activity page
    ------------------------------------------------ */
    
    add_action( 'wp', 'huddle_redirect_to_activity' );
    
    function huddle_redirect_to_activity() {
    	if( is_user_logged_in() && is_front_page() ) {
    		wp_redirect( site_url() . '/' . bp_get_activity_root_slug() );
    	}
    }

    Thanks again guys, you rock!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.