when returns wp_errors or 0 , how to set conditional tag

I am making front-end post submit. and I almost completed.
I want to redirect to specific page after submitting post in front-end successfully.

I am using this function.

wp_insert_post( array $postarr, bool $wp_error = false )

and this returns :

The post ID on success. The value 0 or WP_Error on failure.

$post_id = wp_insert_post( $post_data );
if( !$post_id || ?? ){
wp_redirect( site_url(‘/compledted/’) );
}

This is my code to make.I just want to redirect when submitting post is successfully finished. but I exactly don’t know how to set if( ) conditions.
can you help me?
Thank you.

Read more here:: when returns wp_errors or 0 , how to set conditional tag

Leave a Reply

Your email address will not be published. Required fields are marked *