Swap home page based on user role, Elementor layout breaking

I do believe I’ve got it. Here’s the code:

// Display different home page for dealer vs consumer
if( is_user_logged_in() ) {

  $current_user = wp_get_current_user();
  $user = new WP_User($current_user -> ID);

  if (in_array('Wholesale', $user->roles)){

    $page = get_post(2885);
    update_option( 'page_on_front', $page->ID );
    update_option( 'show_on_front', 'page' );

  } else {

    $page = get_post(2847);
    update_option( 'page_on_front', $page->ID );
    update_option( 'show_on_front', 'page' );  

  }
} else {

  $page = get_post(2847);
  update_option( 'page_on_front', $page->ID );
  update_option( 'show_on_front', 'page' );

}

I’d be lying if I said I’m positive I understand it. However, from what I gather my original code was essentially trying to change the page content in the middle of that content actually being spat out.

On the other hand, this code (a spin on this: https://stackoverflow.com/questions/20039607/different-wordpress-front-page-for-logged-out-and-logged-in-users) actually changes the front page setting before WordPress grabs it to pull the data.

It’s like telling a worker to grab the correct product off the shelf as opposed to trying to shove the right product in their hands after they’ve grabbed the wrong one.