Server changed to a new datacenter. Now purchase button for new members are not working.

My server has changed to a new data center and after that we started experiencing the time out issue with Membership 2. The only difference between the two servers is that the old server was running PHP 5.5 and the new server is running PHP 5.6.

The issue started appearing after being moved to the new data center, no other change was applied and Membership was working fine before that.

  • Ash

    Hello Adrian

    I can see you are using Yoast, and after the latest update of Yoast there is a conflict between M2 and yoast. Our developer is working with the Yoast team and we will release an update very soon.

    For now, you can try either of the following two solutions:

    #1. You can use the following code:

    add_action( 'ms_model_before_save', function( $model ) {
        if( is_a( $model, 'MS_Model_Relationship' ) || is_a( $model, 'MS_Model_Invoice' ) )
        {
            add_filter( 'transient_wpseo_meta_table_accessible', 'm2_yoast_seo_fix' );
        }
    } );
    
    add_action( 'ms_model_after_save', function( $model ) {
        if( is_a( $model, 'MS_Model_Relationship' ) || is_a( $model, 'MS_Model_Invoice' ) )
        {
            remove_filter( 'transient_wpseo_meta_table_accessible', 'm2_yoast_seo_fix' );
        }
    } );
    
    function m2_yoast_seo_fix() {
        return false;
    }

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    OR

    #2: Download the attached file, unzip and replace in the location: /wp-content/plugins/membership/app/model/class-ms-model-invoice.php

    Make sure you delete cache if you have any, after making the change.

    Let me know if that works for you. Have a nice day!

    Cheers,
    Ash

  • Adrian

    Thank you for the very thorough reply - while the issue was urgent and I did not have time to complete the above tasks, I was able to delete the Yoast plugin, and it appeared to solve one of the issues we are having with Membership 2. The other issue, I believe is related to our version of MySQL or PHP, which Ive asked the web host to update.

    An important note is that I tried DEACTIVATING the Yoast (and all plugins but Membership 2) before, and that did NOT solve the issue. The only way to solve it was to fully delete the Yoast plugin. I will check back in once the server configurations are completed, and confirm that the issue was resolved. There could always be something weird after the server configurations are done that may interfere with the above, working fix.

  • Ash

    Thanks for the explanation.

    An important note is that I tried DEACTIVATING the Yoast (and all plugins but Membership 2) before, and that did NOT solve the issue.

    I think there was a cached version of the browser you were testing in and that was still showing the error when you deactivated yoast. In cases like this, always better to clear cache after making any changes (if you have any caching plugin) and check the issue on incognito mode.

    And sure, after the update of server configuration, do test one more time and let us know :slight_smile:

    Have a nice day!

    Cheers,
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.