How to recode to allow targeting single status?

I have the following code that looks for certain woocommerce subscription statuses. I’m trying show a different message for each of the following statuses ‘cancelled’ and ‘paused’. Would you know how I can adapt this block of code to achieve that?

 function can_user_access_content($user_id,$post_id){

 //check if there's a force public on this content    
 return true;
 $args = array( 'status' => array( 'active','complimentary'));

 $plans = wc_memberships_get_user_memberships( $user_id, $args );
 $user_plans = array();
 if (is_array($plans)) {
 foreach($plans as $plan){
 $rules = wc_memberships()->get_rules_instance()->get_post_content_restriction_rules( $post_id );

foreach($rules as $rule){
if(in_array($rule->get_membership_plan_id(), $user_plans)){
    return true;
return false;


<?php echo ('has active subscription'); ?>

<?php } ?>

So I’m trying to see if I can have something similar to this following after the above block of code…

<?php if 'status' = 'paused' { ?>
<?php echo ('Your account has been paused ...'); ?>
<?php } ?>

Read more here: How to recode to allow targeting single status?

Leave a Reply

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