Hi @Radu
I have used your code for the same purpose as outlined by @samuelhatton. Unfortunately the code interrupts the correct loading of the homepage. The head loads but not the content. When refreshing the page, the content loads successfully. I am using the code below in functions.php of the child theme to use a different homepage for users (buddypress activity) than for visitors.
COPY CODE
// set activity as homepage for logged in users
function switch_homepage() {
if ( is_user_logged_in() ) {
$page = 6; // for logged in users
update_option( 'page_on_front', $page );
update_option( 'show_on_front', 'page' );
} else {
$page = 9517; // for logged out users
update_option( 'page_on_front', $page );
update_option( 'show_on_front', 'page' );
}
}
add_action( 'init', 'switch_homepage' );
Do you have any suggestions please? Thanks.