Forum Replies Created
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
Daniel
ParticipantOn it’s own.
Daniel
ParticipantI 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');Daniel
ParticipantI 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!
Daniel
ParticipantUnfortunately 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?
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)