detect your custom post type in WordPress

are you looking for get_post_type?

You can use it to get any CPT type by slug and use it conditionally

For instance:

function filter_the_content( $content ) {
  if ( ! is_user_logged_in() && 'my_cpt' == get_post_type() ) {
    return "Content reserved to logged in users";
  }

  return $content;
}

add_filter( 'the_content', 'filter_the_content' );

The docs:

https://developer.wordpress.org/reference/functions/get_post_type/