wp_insert_post() get Fatal Error from Plugin

So If I understand correctly you are creating a custom import plugin to wordpress outside the normal wordpress scope.

Therefore you don’t have access to the functions inside .pluggable.php like is_user_logged_in you can redefine them in your plugin or you can just use

require_once( ABSPATH . "wp-includes/pluggable.php" );

You will also not be able to use wp_insert_post without

require_once( ABSPATH . "wp-includes/wp-load.php" );

loading the WordPress environment in your naked PHP is most often bad practice.

I would recommend loading your plugin within the WordPress environment. You can do this by rendering your form with a shortcode or a custom template than all these functions will be available to you.