Skip to content

Instantly share code, notes, and snippets.

@JarrydLong
Created January 15, 2026 11:35
Show Gist options
  • Select an option

  • Save JarrydLong/d9a45e3f4f28e6a8d4839c136708d3a1 to your computer and use it in GitHub Desktop.

Select an option

Save JarrydLong/d9a45e3f4f28e6a8d4839c136708d3a1 to your computer and use it in GitHub Desktop.
<?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