Created
August 27, 2015 10:51
-
-
Save gnikolopoulos/43d5cf068abb57597ebc to your computer and use it in GitHub Desktop.
[Wordpress] Different homepage for logged in users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function switch_homepage() { | |
if ( is_user_logged_in() ) { | |
$page = 2516; // for logged in users | |
update_option( 'page_on_front', $page ); | |
update_option( 'show_on_front', 'page' ); | |
} else { | |
$page = 2; // for logged out users | |
update_option( 'page_on_front', $page ); | |
update_option( 'show_on_front', 'page' ); | |
} | |
} | |
add_action( 'init', 'switch_homepage' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello there, I started a little research on how to change the homepage for users once they are either logged in or logged out just as this code does.
but it looks like 'switch_homepage' effects the database itself everytime. so it causes confusion when two users acces the site and one is logged in and one is logged out