# Paid Memberships Pro: Renewal Reminder Banner

> Shows a banner across the top of the site to members whose level ends within the next few days, with a link to renew.

- Type: PHP
- Runs: Frontend only
- Category: [Memberships](https://wpide.com/library/category/memberships/)
- Tags: pmpro, renewal, banner
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/pmpro-renewal-reminder-banner/

## Code

```php
if ( ! function_exists( 'pmpro_getMembershipLevelForUser' ) ) {
    return;
}

$wpide_pmpro_warn_days = 7;

add_action( 'wp_body_open', function () use ( $wpide_pmpro_warn_days ) {
    if ( ! is_user_logged_in() ) {
        return;
    }

    $level = pmpro_getMembershipLevelForUser( get_current_user_id() );

    if ( empty( $level->enddate ) ) {
        return;
    }

    $left = (int) $level->enddate - time();

    if ( $left < 0 || $left > $wpide_pmpro_warn_days * DAY_IN_SECONDS ) {
        return;
    }

    printf(
        '<div class="wpide-pmpro-renew" role="status" style="padding:.75em 1em;text-align:center;background:#fff4ce;color:#3c2f00">%1$s <a href="%2$s" style="color:inherit;font-weight:600">Renew now</a></div>',
        esc_html( sprintf( 'Your %1$s membership ends on %2$s.', $level->name, wp_date( get_option( 'date_format' ), (int) $level->enddate ) ) ),
        esc_url( pmpro_url( 'checkout', '?level=' . (int) $level->id ) )
    );
} );
```

## Notes

Only levels with an end date trigger the banner; automatically renewing subscriptions don't.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Paid Memberships Pro: Renewal Reminder Banner" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
