GDPR check box disappears in Pro Sites signup form

I’ve found a bug in Pro Sites plugin that is causing the GDPR check box that appears at the end of the signup form (after enabling the default WP Privacy Settings in the main site) to disappear if the New Blog Template plugin is active on the site too and for some reason the user forgets to check the GDPR check box and tries to register the site directly.

That causes the user to not be able to register the new site because the GDPR check box is not visible anymore and checking this box it’s requested in order to register a new site (to register the site after skipping this, it’s necessary to reload the page and to re-enter the site details because after reloading the page the checkbox is visible again).

So, if the New Blog Template is active on the site, to be able to register a new site, the user should NOT forget to check the GDPR checkbox because if he/she skips checking it and clicks directly on the “Reserve your site” button, he/she will need to reload the page to be able to register the new site.

  • Ben

    Just so everybody can get thing moving quickly, the quick fix I wrote is:
    in file pro-sites-files/lib/psts-gdpr.php

    make changes the function add_privacy_policy_confirmation :

    start at around line 98:
    Change
    $privacy_link = get_option( 'wp_page_for_privacy_policy', 0 );
    to
    $privacy_link = get_blog_option( 1, 'wp_page_for_privacy_policy', 0 );

    We need to do this because wpmudev plugin Blog Templates might have a hidden bug in that its somehow using switch_to_blog ...but not managing its scope and switching back properly...as a result its revealing a problem in blog templates plugin that needs to be addressed as it might have unforeseen consequences again somewhere else...

    in the function you also need to find:
    $privacy_link = esc_url( get_permalink( $privacy_link ) );
    and change it to
    $privacy_link = esc_url( get_blog_permalink( 1, $privacy_link ) );

    and finally in the function we need to also change:

    if ( empty( $privacy_link ) || 'publish' !== get_post_status( $privacy_link ) ) {

    to

    if ( empty( $privacy_link ) ) {

    get_post_status can only check the status while in a specific blog, there is no option to specify it to a blog id, and because switch_to_blog is an expensive function (as stated here: https://codex.wordpress.org/WPMU_Functions/switch_to_blog) that shouldn't be used on the front end (and this area is indeed generating front end content) it should be avoided. I think the odds of somebody creating their privacy link but not publishing it are low and so I am okay with the "publish check" not being hit if it saves me from not having to use switch_to_blog function.

    So in summary to Joel and Panos Adam Czajczyk

    1. This pro-sites bug reveals an issue in blog templates plugin (possibly another bug) that needs to be investigated.
    2. This is my quick fix to be applied to pro-sites
    3. This took me 2-3 attempts to convince wpmudev support staff to believe its a bug...with the very nice spaniard being open minded to see it through. It took me a full night, and half day to identify where it was coming from, so I hope my efforts are appreciated here and matched to rapidly fix and identify the issue in blog templates plugin in addition to pro-sites.
    4. Because release cycles are so slow...there needs to be a known issues area for wpmudev so the community can better work together for fixes.

  • Joel James

    Hey Ben,

    Thank you for the detailed report and the suggestion.

    Please note that the get_blog_option and get_blog_permalink functions are using switch_to_blog inside them. So we can't avoid it's usage anyway. Better we use switch_to_blog at the top and then restore to the current one, to make sure we are using privacy page from the main site. I've added this fix to Pro Sites and will be available on next release :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.