You don’t have to re-invent the wheel.
(Or hack the core…)
Just use output buffering:
function ob_wp_content($display = true) {
global $post;
ob_start();
the_content();
$output = ob_get_contents();
ob_end_clean();
if(!$display) {return $output;} else {print $output;};
}
Also, wrap the $output so you can choose a simple “$display” flag to make this function either a “getter” or a “printer.” Wrap all the WP functions this way to maintain standards throughout your templates.