About your considerations:-
- Yes true! It will update the page on every visit.
- The database will be updated more frequently based on which user making a request. But there will be no incorrect output.
- The better way I suggest using a
template_include
filter. Assign a static front page then apply the template to that page by checking if user logged in or not. Thus you can display different layout/design to logged-in users and visitor.
See this example:-
add_filter( 'template_include', 'home_page_template', 99 );
/**
* Home page Template based on user
* @param type $template
* @return type
*/
function home_page_template( $template ) {
if (!is_front_page()) {
return $template; //Return if not home page
}
$new_template = false;
if (is_user_logged_in()) {
$new_template = locate_template( array( 'logged-in-users.php' ) );
} else {
$new_template = locate_template( array( 'not-logged-in-users.php' ) );
}
if ( !empty($new_template) ) {
return $new_template ; //Only return if template exist
}
return $template; //Always return value from filter
}
For the rest of the things you can create two menus for logged-in and guest users and call them conditionally in header file. To revoke the access to some pages/posts for guest users use init
hook with is_user_logged_in()
and do temporary redirect to some page. You can search this site for examples of this method.