1. Home
  2. Paywall
  3. How to show “Renew Now” button

How to show “Renew Now” button

Most of the subscriptions in sites managed by PaywallProject are recurring. Only a small percentage of users have a subscription that is non-recurring.

For people like them, you can provide a button to renew their subscription. This is the custom code that you need to add:

<?php
/**
 * [ppaccess_renew_button] — shows a "Renew Subscription" button to logged-in
 * subscribers on a NON-recurring plan whose access expires within 7 days
 * (or has already lapsed). Drop into your theme's functions.php or a mu-plugin.
 */
function ppaccess_renew_button_shortcode() {
	if ( ! is_user_logged_in() ) {
		return '';
	}

	// Guard: only run if PaywallProject is active.
	if ( ! class_exists( '\PaywallProjectAccess\Domain\Subscriber' ) ) {
		return '';
	}

	$user_id    = get_current_user_id();
	$subscriber = \PaywallProjectAccess\Domain\Subscriber::for_user( $user_id );
	if ( ! $subscriber ) {
		return '';
	}

	// Recurring subscriptions renew themselves via Stripe — nothing to prompt.
	// A non-recurring plan has no Stripe subscription id.
	if ( '' !== $subscriber->subscription_id() ) {
		return '';
	}

	$expires = $subscriber->expires_at(); // Unix timestamp; 0 = never expires.
	if ( $expires <= 0 ) {
		return ''; // "Never" — nothing to renew.
	}

	// Show when expiring within the next 7 days, or already expired.
	$window = strtotime( '+7 days' );
	if ( $expires > $window ) {
		return '';
	}

	$level_id = $subscriber->level_id();
	if ( ! $level_id ) {
		return '';
	}

	$levels = new \PaywallProjectAccess\Subscriptions\LevelRepository();
	$level  = $levels->find( $level_id );

	// Only non-recurring, non-free levels.
	if ( ! $level || $level->recurring || $level->price <= 0 ) {
		return '';
	}

	$urls       = new \PaywallProjectAccess\Frontend\FrontendUrlResolver(
		new \PaywallProjectAccess\Support\Settings()
	);
	$renew_link = $urls->subscribe_level_url( $level->slug );

	$out  = '<a href="' . esc_url( $renew_link ) . '" class="ppaccess-renew-button">'
		. esc_html__( 'Renew Subscription', 'paywall-project-access' ) . '</a>';
	$out .= '<style>
		.ppaccess-renew-button {
			display: inline-block;
			padding: 10px 20px !important;
			background-color: #013368;
			color: #fff !important;
			text-decoration: none !important;
			border-radius: 5px;
			font-size: 16px;
			font-family: helvetica;
			font-weight: 600;
			transition: background-color 0.3s ease;
		}
		.ppaccess-renew-button:hover { background-color: #005f8c; }
	</style>';

	return $out;
}
add_shortcode( 'ppaccess_renew_button', 'ppaccess_renew_button_shortcode' );

This custom code modifies the “Update Card” button to be “Renew Now” if their subscription will expire in 90 days.

It will produce a shortcode option (see below) that you can apply anywhere.

[ppaccess_renew_button]
Updated on July 11, 2026
Was this article helpful?
Get more help
Can't find the answer you're looking for? Get in touch.
Contact support