Site icon Hip-Hop Website Design and Development

Set front_page programatically after user login via query, while leaving site option alone

I want to change the front page based on who is logged in.

If User_Bob is logged in, the front page is "Bob" [post id: 123]. If User_Jane is logged in the front page is "Jane"[post ID: 555]. If no user is logged in, the front page is "Main"[post ID:222].

Many other solutions recommend changing options like:

update_option( 'page_on_front', $x->ID );
update_option( 'show_on_front', 'page' );

However, this isn’t feasible, since I want to do it on every page request with every user. Or am I incorrect, and this is a perfectly good technique?

I feel like modifying the main query after the user is logged in is a better option, but I’m not sure which hooks I should use.

How can I override the main query after the user is logged in, to redirect to a specific page ID?