admin管理员组文章数量:1332404
Hi I would love to show different content for logged in users and I don't want to use a redirect, I came up with this idea and it worked well but I am not sure if it is the right way
//Home.php file
If is_loggedin(){
get_header('login');
//My content
get_sidebar('login');
get_footer('login');
}
elseif (! is_loggedin()){
get_header();
//My content
get_sidebar();
get_footer();
}
I am using my own custom made theme, it worked fine but I want to know if it is advisable
Hi I would love to show different content for logged in users and I don't want to use a redirect, I came up with this idea and it worked well but I am not sure if it is the right way
//Home.php file
If is_loggedin(){
get_header('login');
//My content
get_sidebar('login');
get_footer('login');
}
elseif (! is_loggedin()){
get_header();
//My content
get_sidebar();
get_footer();
}
I am using my own custom made theme, it worked fine but I want to know if it is advisable
Share Improve this question asked Jul 9, 2020 at 14:03 Chigbata ChisomChigbata Chisom 111 bronze badge 1 |1 Answer
Reset to default 1What is the is_loggedin() function ? Is that something you have create by yourself ?
Wordpress already got what you need, : is_user_logged_in()
You can use is_home() & is_user_logged_in() to be sure that the content will not display on other page.
As @Ivan Shatsky say's, don't use "else condition" like that.
//Home.php file
if (is_home() && is_user_logged_in()) {
get_header('login');
//My content
get_sidebar('login');
get_footer('login');
} else {
get_header();
//My content
get_sidebar();
get_footer();
}
Not tested !
本文标签: loginDifferent homepage for logged in users
版权声明:本文标题:login - Different homepage for logged in users 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742278901a2445724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
elseif (! is_loggedin()){
instead ofelse {
? User can be logged in or not logged in, there are no third variant. – Ivan Shatsky Commented Jul 9, 2020 at 14:52