From 91b8083b0acf41b0cfc78a7361f311dfee4963af Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Sun, 5 Jan 2025 08:20:13 +0100 Subject: [PATCH] Add fictioneer_filter_patreon_tier_unlock filter --- FILTERS.md | 15 +++++++++++++++ includes/functions/_setup-roles.php | 2 ++ 2 files changed, 17 insertions(+) diff --git a/FILTERS.md b/FILTERS.md index a40f99b9..85f8112f 100644 --- a/FILTERS.md +++ b/FILTERS.md @@ -1245,6 +1245,21 @@ Filters the HTML of the message displayed below the Patreon unlock button. The m --- +### `apply_filters( 'fictioneer_filter_patreon_tier_unlock', $required, $post, $user, $patreon_post_data )` +Filters the boolean to determine whether a post is unlocked via Patreon tier. + +**Parameters:** +* $required (boolean) – Whether the post is unlocked. +* $post (WP_Post) – The post object. +* $user (WP_User) – The current user. +* $patreon_post_data (array) – Relevant Patreon data for the post. + * 'gated' (boolean) - Whether the post has tiers or a cent amount assigned. + * 'gate_tiers' (array) - Tiers that unlock the post. + * 'gated' (int) - Minimum cent amount that unlocks the post. + * 'gate_lifetime_cents' (int) - Minimum lifetime cent amount that unlocks the post. + +--- + ### `apply_filters( 'fictioneer_filter_post_card_footer', $footer_items, $post, $args )` Filters the intermediate output array in the `_card-post.php` partial before it is imploded and rendered. Contains statistics with icons such as the author, publishing date, and comments. diff --git a/includes/functions/_setup-roles.php b/includes/functions/_setup-roles.php index 4daaf855..409f369c 100644 --- a/includes/functions/_setup-roles.php +++ b/includes/functions/_setup-roles.php @@ -546,6 +546,8 @@ function fictioneer_bypass_password( $required, $post ) { ( $patreon_user_data['lifetime_support_cents'] ?? -1 ) >= $patreon_check_lifetime_amount_cents ); + $required = apply_filters( 'fictioneer_filter_patreon_tier_unlock', $required, $post, $user, $patreon_post_data ); + if ( ! $required ) { break; }