Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact
You are here: Home

Daniel

  • Profile
  • Topics Started
  • Replies Created
  • Engagements
  • Favorites

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • January 23, 2018 at 1:59 am in reply to: Downgrade account instead of expire? #13100
    Daniel
    Participant

    On it’s own.

    January 23, 2018 at 12:27 am in reply to: Downgrade account instead of expire? #13087
    Daniel
    Participant

    I put this in my current theme’s functions.php file.

    
    // Simple membership - auto downgrade membership type of Gold to membership type of Silver on membership expiry
    function auto_downgrade_membership_type(){
    	// Is a user logged in?
    	if(SwpmMemberUtils::is_member_logged_in() == true){
    		// Yes. A user is logged in.
    		// Get the user's member id. We will use this later.*
    		$mId = SwpmMemberUtils::get_logged_in_members_id();
    		// Get the user's current membership account state. We will use this later.**
    		$auth = SwpmAuth::get_instance();
    		$account_state = $auth->get('account_state');
    		// Is their current membership level Gold?
    		if(SwpmMemberUtils::get_logged_in_members_level_name() == "Gold"){
    			// Yes. The user's membership type is Gold.
    			// Is their Gold Membership expired?
    			if(SwpmUtils::is_subscription_expired($user) == true){
    				// Yes. The user's Gold membership has expired.
    				// Downgrade the Gold membership to Silver membership - using the user's id variable above* and the id of the desired membership level.
    				SwpmMemberUtils::update_membership_level($mId, 2);
    				// Change the new membership (Silver) account state to "active" because the membership (Gold) account state still thinks it's expired.
    				SwpmMemberUtils::update_account_state($mId, $new_status = 'active');
    			// If an admin manually changed a member's account state to expired (for some reason...) but the membership expire date hasn't been reached.
    			// Check the user's current membership account state.** 
    			}elseif($account_state == 'expired'){
    				// Downgrade the Gold membership to Silver membership type - using the user's id variable above* and the id of the desired membership level.
    				SwpmMemberUtils::update_membership_level($mId, 2);
    				// Change the new membership (Silver) account state to "active" because the membership (Gold) account state still thinks it's expired.
    				SwpmMemberUtils::update_account_state($mId, $new_status = 'active');
    			}else{
    				// No. The user still has Gold privileges.
    			}
    		}else{
    			// No. The user's current membership type is Silver.
    		}
    	}else{
    		// No. There is no user logged in.
    	}
    }
    add_action('init', 'auto_downgrade_membership_type');
    
    January 22, 2018 at 11:38 pm in reply to: Downgrade account instead of expire? #13083
    Daniel
    Participant

    I had to add custom code to my functions.php page but I was able to achieve what I wanted. Thank you for your help. Not sure if I should post the code or not. Let me know if that’s okay.

    Thanks!

    January 22, 2018 at 5:23 pm in reply to: Downgrade account instead of expire? #13078
    Daniel
    Participant

    Unfortunately this wouldn’t work. Upgrading to Gold is meant to be a short term upgrade (about a month) from Silver. Right now having an expired Gold also expires their Silver membership which is meant to last the rest of the year.

    Any other ideas?

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
Next Page »

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy