You are populating the $term
variable with a multidimensional array, but type-and-value checking it (===
) against a string.
Second, you say terms are 'des_1'
and 'des_1'
(with underscore), but are checking for 'des-1'
(with dash).
wp_get_post_terms
will return an array of term objects, so you should might be better of with has_term()
for checking if the term is used on the post.
Tip: this might be better readable (and shorter):
$cstat = in_array( $stat, ["draft", "pending"] )
$cterm = has_term( 'des_1', 'des_num', $post );
return $cstat && $cterm;
or even shorter (but less readable):
return in_array( $stat, ["draft", "pending"] ) && has_term( 'des_1', 'des_num', $post );