[MEMBERSHIP] upgrade membership plugin

I had the free plugin install for membership 2 on a wordpress multisite environemnt and i tried to upgrade and it gives me a blank screen.
During chat session it turns out this is very old membership version(3.2) and it will be hard to upgrade this to correct Pro version (1.1.5).
Any clue to upgrade this?

The goal is I have the wordpress multisite install and I want to set it up so if a user signs up on one site for the 1 month plan, they are signed up to the 1 month plan on the second site added as a user and put into a subscription plan.

I base on this link:
https://premium.wpmudev.org/forums/topic/does-membership-2-pro-sync-memberships-for-users-across-multisite-environments

  • Nithin
    • Support Wizard

    Hi Jonathan,

    Since one of the support agents via Live Chat, did try an upgrade, and that resulted in main site to stop working. I'm bringing this into our developers attention, so that he could give a closer look, and help get to perform a safe upgrade regarding this to latest version of Membership 2 Pro.

    However, it seems like the support access to your site is no longer enabled in your system. I'm getting the following error, when trying to access via Support access:
    The admin did not enable remote access. Please ask the user to grant access.

    Since support access could get terminated unexpectedly, could you please share your sites WP Admin login by using our secure contact form:
    https://premium.wpmudev.org/contact/#i-have-a-different-question

    - To Mark to my attention, the subject line should contain only: ATTN: Nithin Ramdas
    -WordPress admin username
    -WordPress admin password
    -login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls

    Please do follow up in the ticket once you have sent the above credentials. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • Jonathan
    • WPMU DEV Initiate

    I replied to this email and i have not had a response or seen any work done in over a week. I have contacted your support and they cant give an answer.

    I really need this upgrade done ASAP as i have to work on the next step which is joining the memberships based on this post after you have upgraded it.

    https://premium.wpmudev.org/forums/topic/does-membership-2-pro-sync-memberships-for-users-across-multisite-environments

    When will you upgrade the site as nothing has changed??

  • Nithin
    • Support Wizard

    Hi Jonathan,

    Sorry for the delay in getting back to you, the Membership plugin currently installed in your website, is over 3 years old version, and I'm afraid, there isn't any one step solution to upgrade it to Membership 2 Pro. Our SLS developer requires some more time, as it's a complex task, it's something which our SLS team is still going through, and they are currently working on it.

    I do understand the delay could affect your sites workflow, and I could notice that our Chat Support member has already pinged our SLS team about the status of this issue. We'll keep you updated via this ticket once we get further feedback from our developer asap.

    Sorry for any inconvenience due to this. Have a good day ahead.

    Regards,
    Nithin

  • Panos
    • SLS

    Hi Jonathan ,

    Of what I understand the issue you have currently is to upgrade to Membership 2, correct?

    I didn't have any issues on my tests sites so I tried installing it on the site you shared with us but I didn't get the blank screen. I'd like to ask a few things for clarification.

    Did the migration complete successfully?
    If so, at which point did you get the Blank screen and that error message? For example was it during a new member registration? At that point were you using that custom snippet?

    Once we have those cleared we can look into this with some solid start point :slight_smile:

    Kind regards!

  • Jonathan
    • WPMU DEV Initiate

    The plugin is not activated, i would have assumed you installed it and the site would be running on membership 2 pro, the old plugin is still activated and in use.

    Are you able to perform the upgrade or not?

    You said you had a support ticket with SLS for over a week now. I need to know what is happening or if you can do it.

  • Panos
    • SLS

    I did not run the upgrade on your site, as it might go down for a while according to your report. So I would need your confirmation first.

    I can run the upgrade on your site, however it's not clear at which point you get the blank page. Could you also confirm that you have kept a backup too?

    Thanks!

  • Panos
    • SLS

    Hi Jonathan ,

    Good to know it's backed up. Since the Import page is not available anymore I have prepared a mu-plugin which adds a new Submenu, called "Import from M1". When clicking on that, it displays the import screen.

    I tested on your site already, but it seems it didn't import all members, only 200 were from 900+. Since I can't replicate this on my test sites, I will need to go through the import process and insert some checkpoints to monitor what happens and the rest of the members were not imported. I'll keep you posted.

    Kind regards!

  • Panos
    • SLS

    Since I'm not familiar with the old Membership plugin, I had the impression that not all members were imported, since the old one listed 900+ members. I realized that this list includes all users even if they don't have memberships.

    So, regarding the issue about the blank screen, Membership 2 uses Exceptions and it requires display_errors to be active:
    ini_set("display_errors", 1);
    You can ask your host if they can activate it. If not, we need to change several parts in the plugin's code regarding exceptions handling so I will have to consult with the developer about this. In any case please let us know. Currently I have de-activated Membership 2 plugin.

    As for the import, it depends on how you need it to work on your multi-site. I noticed that you have the :
    define( "MS_PROTECT_NETWORK", true );
    in your wp-config.php, which handles the members network wide. In the way that Membership Premium (1) was presenting members, it looks like you need to use it per sub-site, so I imported members for main site.

    In order to them, you need to activate Membership2 Pro (you can activate it Network wide), but you need to comment out this line, mentioned above, from your wp-config.php file:
    define( "MS_PROTECT_NETWORK", true );

    Please have a look and let us know if you need us to re-import network wide.

    Kind regards!

  • Jonathan
    • WPMU DEV Initiate

    I have added ini_set("display_errors", 1);

    After you upgrade it so it works.

    I previously added the define( "MS_PROTECT_NETWORK", true ); though i have now commented that out.

    As i need to get this script working:

    https://premium.wpmudev.org/forums/topic/multisite-upgrade-and-subscriptions?replies=3#post-1369359

    So when a user signs up to a plan on the main site they are also added to a plan on the sub site.

    This is very important.

    Lastly will i be able to upgrade my site to PHP 7.2 after the plugin is upgraded.

  • Panos
    • SLS

    Hi there Jonathan ,

    I have commented out the display_errors part, as it turned out that it doesn't help.

    For now I have commented out the line that causes this issue and I have informed the developer about this. Will keep you posted regarding this issue.

    I have tested registering a member on your site. For that I activated Membership 2 plugin individually on each sub-site, I didn't Network Activate it. I also added a sandbox account for PayPal which you can keep in order to test, after testing you need to remove or replace it.

    In the mu-plugins folder I added a new mu-plugin file called ms_add_network_member.php which contains the following snippet :

    function ms_add_network_member( $invoice, $subscription ) {
    
    	if ( ! is_main_site() ) {
    		return;
    	}
    
    	$target_site_id 			= 2;
    	$associated_memberships 	= array(
    									34491 => 312,
    									34492 => 312,
    									34493 => 312,
    									34494 => 312,
    									34495 => 312,
    									34496 => 312,
    									34497 => 312
    								);
    
    	$member 					= $subscription->get_member();
    	$cur_membership_id 			= $subscription->get_membership()->id;
    
    	if ( ! isset( $associated_memberships[ $cur_membership_id ] ) ) {
    		return;
    	}
    
    	switch_to_blog( $target_site_id );
    
    	add_user_to_blog( $target_site_id, $member->id, 'subscriber' );
    
    	$new_member 				= MS_Factory::load( 'MS_Model_Member', $member->id );
    	$new_subscription 			= $new_member->add_membership( $associated_memberships[ $cur_membership_id ] );
    	$invoice 					= $new_subscription->get_current_invoice();
    	$invoice->pay_it();
    
    	$new_subscription->status 	= MS_Model_Relationship::STATUS_ACTIVE;
    	$new_subscription->save();
    	MS_Model_Event::save_event( MS_Model_Event::TYPE_MS_SIGNED_UP, $new_subscription );
    
    	$new_member->is_member 		= true;
    	$new_member->save();
    
        restore_current_blog();
    
    }
    
    add_action( 'ms_invoice_paid', 'ms_add_network_member', 20, 2 );

    Since I noticed you have paid memberships, it is better to add the subscription on subsite once the original one is paid. So this is what snippet does. Once the subscription is paid, it adds the user to the sub-site and then adds the associated membership to that user in the sub-site.

    As you have noticed, the membership ids are not the ones you need, so you will need to change this part:

    $associated_memberships 	= array(
    									34491 => 312,
    									34492 => 312,
    									34493 => 312,
    									34494 => 312,
    									34495 => 312,
    									34496 => 312,
    									34497 => 312
    								);

    The first column contains the ids from the main blog, and the second one the ids of the sub-site.

    Then you can go ahead and do your testing. I have deactivates Membership 2 in both sites, so will first need to activate it per sub-site. Then you can try choose a membership from:
    https://yoursite.com/memberships-2/ (it should redirect to register-2)

    Please let us know how it goes on your side!

    In regards to:

    Lastly will i be able to upgrade my site to PHP 7.2 after the plugin is upgraded.

    There shouldn't be any issues

    Kind regards!

  • Jonathan
    • WPMU DEV Initiate

    I have activated both plugins and updated the snippet with the ID's.

    When I click on a plan to register from the main site e.g. recurring monthly it takes you to the registration from when you click sign up then when you fill out the details it just refreshes and goes to the register form again.

    https://mysite.com/register-2/

    Lastly i switched to PHP 7.2 and it draws a blank screen. You can see here.

    https://mysite.com/?wpengine_php=7.2

  • Panos
    • SLS

    Hi Jonathan ,

    It seems some plugin or custom snippet forces redirect upon registration. I didn't manage to find the source but I have added an action that overrides the redirect and should link to the payment table. For this I hae added the following snippet at the bottom of the file mu-plugins/ms_add_network_member.php:

    add_action( 'wp_login', function(){
    	if ( ! isset( $_REQUEST['action'] ) || 'register_user' != isset( $_REQUEST['action'] ) || ! isset( $_REQUEST['membership_id'] ) ) {
    		return;
    	}
    
    	// Go to membership signup payment form.
    	if ( empty( $_REQUEST['membership_id'] ) ) {
    		$redirect = esc_url_raw(
    			add_query_arg(
    				array(
    					'step' => MS_Controller_Frontend::STEP_CHOOSE_MEMBERSHIP,
    				)
    			)
    		);
    	} else {
    		$redirect = esc_url_raw(
    			add_query_arg(
    				array(
    					'step' => MS_Controller_Frontend::STEP_PAYMENT_TABLE,
    					'membership_id' => absint( $_REQUEST['membership_id'] ),
    				),
    				MS_Model_Pages::get_page_url( MS_Model_Pages::MS_PAGE_REGISTER )
    			)
    		);
    	}
    
    	wp_safe_redirect( $redirect );
    	exit;
    
    }, 1 );

    I did a few tests and seems to work fine. Could you do a few tests on your side and let us know how it goes on your side?

    I also changed the permalinks of the Membership 2 pages (so they don't have the "-2" in their urls)

    As for the site with php 7.2 could you please provide access to that site too? I would need admin and ftp access. You can send those credentials privately as Nithin mentioned in his first reply.

    Kind regards!

  • Panos
    • SLS

    It seems site doesn't load cause of the following plugins:
    wassup which throws a PHP Parse error
    siteorigin-panels which throws a Fatal Error

    For now I have renamed those to:
    wassup_ and
    siteorigin-panels_
    accordingly so they get deactivated and site is now running. I would recommend to either switch back to previous php version or update/replace those plugins.

    Kind regards!

  • Panos
    • SLS

    Could you share a screenshot? I just tested on your site and didn't have any issue there. I was able to continue to paypal, I managed to pay successfully and member's subscription was active. Here's a screenshot on what I see in the link you shared:

    Could you also try deactivating other plugins so we can exclude any plugin conflict situation?

    Thanks!

  • Panos
    • SLS

    I forgot to mention that when you visit the link you shared, you need to be logged in. It just hit me as I realized you mentioned that you see the registration form. If you visit that page and user is not logged in then he should see the registration form.

    Cheers!

  • Jonathan
    • WPMU DEV Initiate

    Everything seems to be ok.

    I check the membership numbers on the old plugin is around 390 or so and on the updated plugin it is only 89.

    Do you know how I can import the subscribers to the updated plugin so all of them are there.

  • Panos
    • SLS

    Hi Jonathan !

    Apologies for the delay. I wasn't sure about which were actual members or not, as in Membership 1 it would list all users in the members list. I had added a mu-plugin that would list member's from Memberehip1 db table but I see it's not there now, which is good.

    Good to know you have it sorted!

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.