Add custom PHP and HTML to the_content()

i´m not sure to understand your question, but why not use this logic in your function?

if ( is_user_logged_in() ) {
    echo 'Welcome, registered user!';
    do your stuff PHP and inject in content...
} else {
    return standard content or block it;
}

and maybe additional test to limit with current_user_can( $capability ), and so on…