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 |1 Answer
Reset to default 1I 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
版权声明:本文标题:php - Change homepage content if user is logged in - BuddyPress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741681071a2392171.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
front-page.php
- andis_user_logged_in()
to show different content. – Nicolai Grossherr Commented Oct 6, 2015 at 16:30