Member Access Force Login

This page provides the history and current status of the plugins used to control access to “private” pages and posts.

Note: If you want to create a quick/temporary private page, you may edit the page /web2/members/nsc-private-area/private/. That page is intended as a generic private page and is already included in the functions.php file.

From 2009-2018, the Member Access Plugin was installed on NSC.CA (but not on the subwebs) to control login access on posts and pages by adding a radio-button section at the bottom of the Classic Editor page. The radio buttons could be used to change the access from public to private, forcing a WP login.

In 2018, the plugin was removed from the WordPress Plugin library. For security reasons, D. Servranckx converted it to a “private” plugin and renamed it “NSC Member Access”. He updated the plugin as needed to keep it current with PHP versions.

This plugin only worked with the WP Classic Editor, so a replacement compatible with the default Block Editor (Gutenberg) was needed as the Classic Editor (a plugin), was set to expire in 2022.

In 2021, a new plugin, “WP Force Login”, was installed and activated on the NSC.CA website, and the “NSC Member Access” plugin was deactivated. This new plugin is open source and very light-weight. Details are available in https://wordpress.org/plugins/wp-force-login/ .

As this new plugin forces user login by default, a filter function, my_forcelogin_bypass, was manually added to the current child theme php functions file /web2/wp_content/theme/twentytwelveGeneric/functions.php to reverse the behavior so that login would only be required for posts and pages contained in a defined list. That list (as of 2021-03-15) looks like this:

// Define the list of URLs – can be posts or pages – requiring WP login to open.
// home_url is something like “https://nsc.ca/web2”, and the part in quotation marks are permalinks.
$disallowed = [
home_url( ‘/members/nsc-private-area/board-documents/’ ),
home_url( ‘/members/nsc-private-area/members-passwords-and-codes/’ ),
home_url( ‘/members/nsc-private-area/nsc-upload-utilities/’),
home_url( ‘/members/nsc-private-area/nsc-upload-utilities/racing-upload-utility-v2/’ ),
home_url( ‘/members/nsc-private-area/nsc-upload-utilities/general-upload-utility-v2/’ ),
home_url( ‘/members/nsc-private-area/mooring-allocations/’ ),
home_url( ‘/members/parking-permits/’ ),
home_url( ‘/pr/brand/’ ),
home_url( ‘/site-map4/’ ),
home_url( ‘/library/how-to/’ ),
home_url( ‘/membership/anniversary-membership-burgees-list/’ ),
];

To add a new URL to the list:

  1. use FTP to download functions.php mentioned above to your own device;
  2. open the downloaded file;
  3. scroll to the function called my_forcelogin_bypass;
  4. in the list $disallowed, copy and paste one of the existing entry under the last entry;
  5. replace the URL in the copied entry so it matches the new post or page permalink;
  6. save functions.php;
  7. upload functions.php back to the server;
  8. test the post or page you have just added.


    Page Updated: 2026-05-06.
    Page maintained by D. Servranckx.

    Page maintained by D. Servranckx