Created
September 9, 2025 07:56
-
-
Save andrewlimaza/141f97b129f168d83c615d65f44ad359 to your computer and use it in GitHub Desktop.
Filter the subscription delay option for level ID 2 example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Filter the subscription delay option for membership level ID 2 to be 1 year later if checking out in October. | |
| * Change "option_pmpro_subscription_delay_2" to "option_pmpro_subscription_delay_X" for a specific membership level. | |
| * | |
| * @see https://developer.wordpress.org/reference/hooks/option_option/ | |
| * | |
| * Add this custom code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| */ | |
| function my_pmpro_adjust_sub_delay_date( $value, $option ) { | |
| $todays_date = new DateTime(); | |
| // Get the current month (1-12) | |
| $month = (int) $todays_date->format('n'); | |
| /** | |
| * Check if the month is October or later and update the Subscription Delay to be 1 year later. | |
| * This will keep the month and day in tact. Tweak this logic accordingly. | |
| */ | |
| if ( $month >= 10 ) { | |
| // str_replace 'Y1' with the 'Y2' | |
| $value = str_replace( 'Y1', 'Y2', $value ); | |
| } | |
| return $value; | |
| } | |
| add_filter( 'option_pmpro_subscription_delay_2', 'my_pmpro_adjust_sub_delay_date', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment