Created
January 15, 2026 11:35
-
-
Save JarrydLong/d9a45e3f4f28e6a8d4839c136708d3a1 to your computer and use it in GitHub Desktop.
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 //do not copy | |
| /* This recipe will show a list of 'overdue' memberships if the level is within a grace period | |
| * | |
| * You can add this recipe to your site by creating a custom plugin | |
| * or using the Code Snippets plugin available for free in the WordPress repository. | |
| * Read this companion article for step-by-step directions on either method. | |
| * https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| */ | |
| function mypmpro_show_member_overdue(){ | |
| $current_user = wp_get_current_user(); | |
| if( !$current_user ) { | |
| return ''; | |
| } | |
| $levels = pmpro_getMembershipLevelsForUser( $current_user->ID ); | |
| if( empty( $levels ) ) { | |
| return ''; | |
| } | |
| $overdue_levels = array(); | |
| foreach( $levels as $level ) { | |
| $grace_period = (bool)get_user_meta($current_user->ID, 'grace_period_'.$level->id, true); | |
| if( $grace_period ) { | |
| $overdue_levels[] = $level->name; | |
| } | |
| } | |
| if( empty( $overdue_levels ) ) { | |
| return ''; | |
| } | |
| $output = '<div class="pmpro-member-overdue-notice">'; | |
| $output .= '<strong>Your membership is overdue for the following level(s):</strong><br />'; | |
| $output .= '<ul>'; | |
| foreach( $overdue_levels as $level_name ) { | |
| $output .= '<li>' . esc_html( $level_name ) . '</li>'; | |
| } | |
| $output .= '</ul>'; | |
| $output .= 'Please update your payment information to continue enjoying your membership benefits.'; | |
| $output .= '</div>'; | |
| return $output; | |
| } | |
| add_shortcode( 'pmpro_member_overdue', 'mypmpro_show_member_overdue' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment