WordPress Different Home page for loged in and logged out users

I’m trying to set different home pages for logged in users

this working somethimes and somethimes not

if( is_user_logged_in() ) {
$page = get_page_by_path( '/front-page');
update_option( 'page_on_front', $page->ID );
update_option( 'show_on_front', 'page' );
}
else {
$page = get_page_by_path( '' );
update_option( 'page_on_front', $page->ID );
update_option( 'show_on_front', 'page' );
}

Leave a Comment