Using Gravity Forms ‘gform_stripe_no_subscriptions_found_message’ PHP filter

The gform_stripe_no_subscriptions_found_message filter in Gravity Forms allows filtering the message when no subscriptions are found in the Stripe customer portal.

Usage

Apply to all forms:

add_filter('gform_stripe_no_subscriptions_found_message', 'your_function_name', 10, 3);

Specify per form by adding the form id after the hook name:

add_filter('gform_stripe_no_subscriptions_found_message_7', 'your_function_name', 10, 3);

Parameters

  • $message (string): The message being filtered.

More information

See Gravity Forms Docs: gform_stripe_no_subscriptions_found_message

Place this code in the functions.php file of your active theme.

This filter was added in Gravity Forms Stripe Add-On 4.2.

The filter is located in GF_Stripe_Billing_Portal in gravityformsstripe/includes/class-gf-stripe-billing-portal.php.

Examples

Change default no-subscription message

Change the default message when no subscriptions are found to a custom message.

function change_no_subscriptions_message($message) {
    $message = 'No active subscriptions found. Please subscribe to continue.';
    return $message;
}
add_filter('gform_stripe_no_subscriptions_found_message', 'change_no_subscriptions_message', 10, 3);

Add custom message for a specific form

Change the default message when no subscriptions are found for a specific form with ID 5.

function change_no_subscriptions_message_for_form_5($message) {
    $message = 'No active subscriptions found for Form 5. Please subscribe to continue.';
    return $message;
}
add_filter('gform_stripe_no_subscriptions_found_message_5', 'change_no_subscriptions_message_for_form_5', 10, 3);

Include the user’s display name in the message

Personalize the message by including the user’s display name.

function personalize_no_subscriptions_message($message) {
    $current_user = wp_get_current_user();
    $message = $current_user->display_name . ', you have no active subscriptions. Please subscribe to continue.';
    return $message;
}
add_filter('gform_stripe_no_subscriptions_found_message', 'personalize_no_subscriptions_message', 10, 3);

Include a link to the subscription page in the message.

function add_subscription_link_to_message($message) {
    $subscription_page_url = 'https://example.com/subscription';
    $message = 'No active subscriptions found. <a href="' . $subscription_page_url . '">Subscribe here</a> to continue.';
    return $message;
}
add_filter('gform_stripe_no_subscriptions_found_message', 'add_subscription_link_to_message', 10, 3);

Display a different message for logged-out users

Show a different message for logged-out users.

function different_message_for_logged_out_users($message) {
    if (!is_user_logged_in()) {
        $message = 'Please log in to view your subscriptions.';
    }
    return $message;
}
add_filter('gform_stripe_no_subscriptions_found_message', 'different_message_for_logged_out_users', 10, 3);