admin管理员组

文章数量:1302544

I'm creating a Social Network using BuddyPress, a good theme for BuddyPress itself and some plugins included with the theme that help me so much in this thing.

I'm trying to do one thing: when the user goes to website, he'll se the website informations, so like "subscribe, this is a good place" etc. But when the user is logged in, I would that in the homepage should appear, instead of the classic homepage, the BuddyPress activity!

How could this be possible? Can I do that?

Is like the thing that does Facebook and so many websites: if your not logged in, you can register and login, if you are logged in, you can see your Facebook home: everything ever in facebook

And I want to do the same on my website!

Thanks to everyone for any help!

I'm creating a Social Network using BuddyPress, a good theme for BuddyPress itself and some plugins included with the theme that help me so much in this thing.

I'm trying to do one thing: when the user goes to website, he'll se the website informations, so like "subscribe, this is a good place" etc. But when the user is logged in, I would that in the homepage should appear, instead of the classic homepage, the BuddyPress activity!

How could this be possible? Can I do that?

Is like the thing that does Facebook and so many websites: if your not logged in, you can register and login, if you are logged in, you can see your Facebook home: everything ever in facebook

And I want to do the same on my website!

Thanks to everyone for any help!

Share Improve this question asked Oct 6, 2015 at 15:13 OptirootOptiroot 134 bronze badges 3
  • In a nutshell: Make use of a custom front page template - front-page.php - and is_user_logged_in() to show different content. – Nicolai Grossherr Commented Oct 6, 2015 at 16:30
  • Thank you for the answer. Is there any way to do something like this with Visual Composer? It was shipped with my theme. – Optiroot Commented Oct 6, 2015 at 16:50
  • Sorry, but I don't know anything about visual composer. – Nicolai Grossherr Commented Oct 6, 2015 at 16:55
Add a comment  | 

1 Answer 1

Reset to default 1

I just wrote some code to do something a bit different, but it should work for what you're trying to do. It's hooked in at the wp hook, which will prevent redirect loop errors. This will go in either a functions.php file or your own custom plugin (recommended).

    add_action('wp','restrictEnterSite');

    function restrictEnterSite(){
    // Make a template of the splash page you'd like to display if user is not logged in
    $homeURL = home_url('/splash-template.php');

    //validate
    if ( $homeURL !== $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] && !is_user_logged_in() ) {

      wp_redirect($homeURL);
        exit;



    }
}

Give this a shot!

本文标签: phpChange homepage content if user is logged inBuddyPress