Thanks for the reply. I eventually got it working by removing get_sidebar(); from single.php in the child theme, and then adding this to functions.php in the child theme:
function showSidebarWhenNeeded()
{
global $post;
$page_id = get_queried_object_id();
$user_id = get_current_user_id();
$author_id = get_post_field( 'post_author', $page_id );
if ( $user_id == $author_id ) {
get_sidebar();
echo '<style>.site-main{ margin-right: 0 !important;}</style>';
}
}
add_action( 'get_footer', 'showSidebarWhenNeeded' );