Membership 2 Registration gets stuck

Login to the site as a user and go to /membership page where you select yearly or lifetime membership and click “submit”. The registration gets stuck at this point, the browser keeps “loading” the page and finally, there’s a 504 timeout” error from nginx.

Further testing showed up that it’s related to child-theme.

  • Ash
    • Code Norris

    Hello Michael-Cyger

    I have just checked at your site and the submit button in membership page worked fine for me. I got the payment page, please check the screenshot.

    [attachments are only viewable by logged-in members]

    So, is the issue fixed? If not, please feel free to suggest if I am missing anything.

    Have a nice day!

    Cheers,

    Ash

  • MC
    • The Incredible Code Injector

    Hi Ash,

    I’ve been working on this issue non-stop, and I think I figured out the issue just before you tried it.

    TLDR: the Yoast SEO plugin conflicts with the Membership 2 Pro plugin.

    I believe there’s a conflict between Membership 2 Pro plugin and the Yoast SEO plugin.

    Every time someone visits a link like /register?membership_id=602, it triggers MS_Controller_Frontend->payment_table(), this function is used to render the payment table. While rendering it also generates and save an invoice as a WordPress post.

    Now Yoast monitors all WordPress posts. It listens on ‘save_post’ hook. Whenever an invoice is saved, it triggers WPSEO_Link_Watcher->process(). This function then applies the filter ‘the_content’. That filter is in turn triggering the payment_table() function.

    They keep calling each other back and forth infinitely.

    This was a similar issue:

    https://wpmudev.com/forums/topic/membership-2-registration-not-working-with-yoast-active

    https://github.com/Yoast/wordpress-seo/issues/8218

    So I think either Yoast needs to be updated or Membership 2 Pro needs to be updated. Until then, I’m disabling Yoast.

    Do you agree?

    Thanks,

    Michael

  • Ash
    • Code Norris

    By the way, you can try the following snippet:

    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.

    Have a nice day!

    Cheers,

    Ash

  • MC
    • The Incredible Code Injector

    Hi Ash,

    I finally got past Black Friday promotions and could try your fix.

    I did the following:

    1. Activated Yoast

    2. Added the code above into my child theme’s functions.php file

    I received a server 500 error when I tried to add a new membership on the membership payment page (https://www.dnacademy.com/register?step=payment_table&membership_id=602):

    https://www.dropbox.com/s/hyxw9da1sozb8em/Screenshot%202017-11-30%2014.47.29.png?dl=0

    Any other ideas on how to fix this?

    Thank you for your help!

    Best,

    MC

  • Katya Tsihotska
    • Ex Staff

    Hi Michael-Cyger

    Hope you’re having a great weekend!

    We already have a beta version of the next plugin update where the conflict with Yoast SEO and some other issues are fixed. You can replace the copy of Membership 2 Pro that’s installed with the copy I’ve attached to the thread here.

    As usual, before doing any changes, I would recommend creating a full backup of your site.

    Kind regards,

    Katya

  • MC
    • The Incredible Code Injector

    Hi Katya Tsihotska,

    I uploaded this beta5 release and it causes a Server 500 error on my site. Then I reverted to the old (currently released) version and all was restored and properly functioning.

    Has this beta been tested in current state?

    Any idea why it caused an error for me?

    Thanks,

    Michael

  • Katya Tsihotska
    • Ex Staff

    Hi Michael-Cyger

    Hope you’re fine!

    Of course, this version of the plugin was tested, I also checked it on my own install and it doesn’t cause such issues. But as it is a beta version it still could have some issues. So, we need to wait for another hotfix or for the plugin update.

    It’s hard to say why it caused an error on your site, as 500 error itself doesn’t give much information about the issue. If you want to diagnose it, it will be needed to enable WP_DEBUG and install this version of the plugin again, so we’ll be able to get more information about the error. If you would like to do this, please go to wp-config.php and change

    define( 'WP_DEBUG', false );

    to

    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    define( 'WP_DEBUG_LOG', true );

    Then install the beta version and once you’ll receive an error, go to /wp-content folder and check if the debug.log file is there. If it is there, download it, save as debug.txt and attach to your next reply.

    I also pinged our developers with regards to this and I’ll post back here if they provide me with any valuable suggestions.

    Kind regards,

    Katya