• Resolved ZaacWilliam

    (@omo9jatoja)


    Good morning lovely peeps of paidmembershipspro.com I need help with how I can show a content when the membership is still active and when it’s expired!

    Me myself this code below is what have tried

    function msgfrpro() {
    	
    	global $current_user;
    
            $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->name); 
    
    	$date = date('d/m/Y');
    
    	$theday = do_shortcode('[pmpro_expiration_date]');
    	
    	$plan = $current_user->membership_level->name;
    
    	
    
      if(((($date < $theday) || ($date == $theday) || ($theday > $date)|| ($date > $theday )))) {
    
    	  
    
    	  $out = '<p style="text-align:justify;">show content for active members that have not expired! </p>';
    
    	
    
    	
    
    } if(($theday == '') || ($theday == '---')) {
    
    	  
    
    	  $out = '<p style="text-align: justify;">show content for user with expired membership or user with no membership </p>'; 
    
    	  
    
      }
    
    	return $out;
    
    } 
    
    add_shortcode('msgfrpro', 'msgfrpro');
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Andrew Lima

    (@andrewza)

    Hi @omo9jatoja

    Thank you for using Paid Memberships Pro.

    Expired user’s are treated the same way as non-members as expired member’s don’t have a membership level whatsoever.

    A workaround for this may be to give user’s a hidden level that has no access to any content when their membership expires or cancels and then you can use that as a reference. You may hook into the pmpro_after_change_membership_level and if the level ID on this hook is 0, this means the user is cancelling. You then can change their level to the hidden/expired level.

    Another way would be to query the database to see if the user had a membership level that isn’t currently in the ‘active’ status and show content based off of that.

    I hope this helps get you started.

    Thread Starter ZaacWilliam

    (@omo9jatoja)

    Was initially looking for something like the code below cause mY site members will need not to cancel they wait for expired day and think if to buy higher or lower level some other time

    if((pmpro_hasExpiredMembershipLevel)) { 
    	  
    	  $out = '<p>show that the membership has expired and a link to buy new one</p>'; 
    	  
    	  
    	 } 

    Is this possible sir?
    Another thing is that am using woocommerce for membership purchases…!

    • This reply was modified 3 years, 6 months ago by ZaacWilliam.
    Plugin Author Andrew Lima

    (@andrewza)

    You may be able to use the pmpro_hasMembershipLevel method, which supports getting expired levels. Here is a link to the function for reference – https://github.com/strangerstudios/paid-memberships-pro/blob/dev/includes/functions.php#L821-L929

    Thread Starter ZaacWilliam

    (@omo9jatoja)

    Mr Andrew thanks for your fast response, can you please teach me further on changing the membership level on the expiration date!

    Something that can go like

    // get current day
    $today = date('d/m/Y');
    //get expiration day
    $expireday = do_shortcode('[pmpro_expiration_date]');
    
    //check if the today is expiration day
    if($today == $expireday) {
    
    //We change change the level to 0
    
    }

    If this can be achieved I’ll be able to use my earliest codes!
    I need your help to do_action change level to ‘0’…..

    • This reply was modified 3 years, 6 months ago by ZaacWilliam.
    • This reply was modified 3 years, 6 months ago by ZaacWilliam.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘HOW TO SHOW/HIDE A CONTENT TEXT BASED ON MEMBERSHIP EXPIRATION DATE’ is closed to new replies.