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

How to show “Renew Now” button

Most of subscriptions in sites managed by Paywall Project are recurring. Only small percentage of user who has subscription that are 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:

// Shortcode to display the Renew Subscription or Update Card button
function leaky_paywall_renew_or_update_button_shortcode() {
    ob_start();

    // Ensure the user is logged in and fetch the subscription details
    if ( is_user_logged_in() ) {
        $user_id = get_current_user_id();

        // Check if the user has access
        if ( function_exists( 'leaky_paywall_user_has_access' ) && !leaky_paywall_user_has_access( $user_id ) ) {

            $mode = leaky_paywall_get_current_mode();
            $site = leaky_paywall_get_current_site();

            $level_id = get_user_meta( $user_id, '_issuem_leaky_paywall_' . $mode . '_level_id' . $site, true );
            $plan = get_user_meta( $user_id, '_issuem_leaky_paywall_live_plan', true );
            $expires = get_user_meta( $user_id, '_issuem_leaky_paywall_live_expires', true );
            $payment_gateway = get_user_meta( $user_id, '_issuem_leaky_paywall_live_payment_gateway', true );
            $payment_status = get_user_meta( $user_id, '_issuem_leaky_paywall_live_payment_status', true );

            // If payment is deactivated and gateway is Stripe, show "Update Card" button
            if ( $payment_status === 'deactivated' && $payment_gateway === 'stripe' ) {
                $update_card_link = site_url( '/my-account/' ); // Adjust this link as needed
                return '<a href="' . esc_url( $update_card_link ) . '" class="update-card-button">Update Card</a>' .
                    '<style>
                        .update-card-button {
                            display: inline-block;
                            padding: 10px 20px !important;
                            background-color: #FFA500;
                            color: #fff !important;
                            text-decoration: none !important;
                            border-radius: 5px;
                            font-size: 16px;
                            transition: background-color 0.3s ease;
                            font-family: helvetica;
                            font-weight: 600;
                        }
                        .update-card-button:hover {
                            background-color: #FF8C00;
                        }
                        .menu-item.menu-item-type-post_type.menu-item-object-page.menu-item-6030 {
                            display: none;
                        }
                    </style>';
            }

            // Show renew button if subscription expires within 90 days or is expired
            $show_renew = false;
            if ( $expires ) {
                $expire_time = strtotime( $expires );
                $now = time();
                $seven_days_from_now = strtotime( '+90 days', $now );

                if ( $expire_time <= $seven_days_from_now ) {
                    $show_renew = true;
                }
            }

            if ( $level_id && ( empty( $plan ) || $plan === 'Non-Recurring' ) && $show_renew && $payment_gateway !== 'Free Registration' ) {
                if ( function_exists( 'get_leaky_paywall_subscription_level' ) ) {
                    $level = get_leaky_paywall_subscription_level( $level_id );
                    $renew_link = add_query_arg( 'level_id', $level_id, site_url( '/register/' ) );

                    return '<a href="' . esc_url( $renew_link ) . '" class="renew-button">Renew Subscription</a>' .
                        '<style>
                            .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;
                                transition: background-color 0.3s ease;
                                font-family: helvetica;
                                font-weight: 600;
                            }
                            .renew-button:hover {
                                background-color: #005f8c;
                            }
                            .menu-item.menu-item-type-post_type.menu-item-object-page.menu-item-6030 {
                                display: none;
                            }
                        </style>';
                }
            }
        }
    }

    return ''; // Return nothing if conditions aren't met
}
add_shortcode( 'renew_or_update_button', 'leaky_paywall_renew_or_update_button_shortcode' );

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

It will produce a shortcode [renew_or_update_button] that you could apply it anywhere.

Updated on February 22, 2026
Was this article helpful?
Get more help
Can't find the answer you're looking for? Get in touch.
Contact support