Fix password bypass cache issue (again)
This commit is contained in:
parent
763ecf6c60
commit
4eec1f9b1f
@ -549,7 +549,7 @@ The custom HTML block is the best way to add special elements to the content, su
|
||||
|
||||
You can grant logged-in users access to password-protected content via Patreon membership, either by selected tiers or pledge thresholds or both. See [installation guide](INSTALLATION.md#patreon-integration) for more details. Prices are stored in **cents** (¢100 to $1), independent of your campaign currency. You still need to set a password for the post and stories **do not** pass down gates to chapters due to technical reasons.
|
||||
|
||||
**Caching:** If you use a cache plugin, make sure that password-protected posts are not cached or this might not work properly. The LiteSpeed Cache plugin should be fine, but anything else might need additional configuration.
|
||||
**Caching:** If you use a cache plugin, make sure that password-protected posts are not cached or this might not work properly. The LiteSpeed Cache, WP Super Cache, and W3 Total Cache plugins should be fine, but anything else might need additional configuration.
|
||||
|
||||
**Free Tier:** If you want to gate content behind the free tier (only following, not paying), you can just add the tier alongside the others. If that is too inconvenient because you got too many tiers, you can use the pledge threshold to include any tier equal to or above a certain amount in cents (e.g. 300 for $3.00), either globally or post by post.
|
||||
|
||||
@ -557,7 +557,7 @@ You can grant logged-in users access to password-protected content via Patreon m
|
||||
|
||||
You can grant logged-in users access to password-protected content by unlocking specific posts. Just open the admin profile page of the user, search for the posts you want to unlock, add them and save. Chapters inherit the unlock of the story. Roles other than administrators require both the **Edit Users** and **Unlock Posts** capabilities to assign unlocked posts to users, which can be assigned in the role manager.
|
||||
|
||||
**Caching:** If you use a cache plugin, make sure that password-protected posts are not cached or this might not work properly. The LiteSpeed Cache plugin should be fine, but anything else might need additional configuration.
|
||||
**Caching:** If you use a cache plugin, make sure that password-protected posts are not cached or this might not work properly. The LiteSpeed Cache, WP Super Cache, and W3 Total Cache plugins should be fine, but anything else might need additional configuration.
|
||||
|
||||
**Patreon Gate:** Post unlocks are normally independent of Patreon, but you can gate them behind a global pledge threshold in cents to limit the feature to paying patrons only. This is in addition to any other Patreon gates.
|
||||
|
||||
|
@ -462,11 +462,28 @@ function fictioneer_bypass_password( $required, $post ) {
|
||||
return $cache[ $cache_key ];
|
||||
}
|
||||
|
||||
// Default (make sure the cookie is set up properly)
|
||||
// Default
|
||||
remove_filter( 'post_password_required', 'fictioneer_bypass_password' );
|
||||
$required = post_password_required( $post );
|
||||
add_filter( 'post_password_required', 'fictioneer_bypass_password', 10, 2 );
|
||||
|
||||
// Notify cache plugins to NOT cache the page regardless of access
|
||||
if ( $required ) {
|
||||
// LiteSpeed Cache
|
||||
do_action( 'litespeed_control_set_nocache', 'nocache due to password protection bypass.' );
|
||||
|
||||
// WP Super Cache, W3 Total Cache, Hummingbird, and probably more
|
||||
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
|
||||
define( 'DONOTCACHEPAGE', true );
|
||||
}
|
||||
|
||||
// Cache Enabler
|
||||
add_filter( 'cache_enabler_bypass_cache', '__return_true' );
|
||||
|
||||
// WP Rocket
|
||||
add_filter( 'do_rocket_generate_caching_files', '__return_false' );
|
||||
}
|
||||
|
||||
// Always allow admins
|
||||
if ( current_user_can( 'manage_options' ) ) {
|
||||
$cache[ $cache_key ] = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user