Using Gravity Forms ‘gform_stripe_subscriptions_self_serve_markup’ PHP filter

The gform_stripe_subscriptions_self_serve_markup Gravity Forms PHP filter allows you to modify the subscriptions list markup or the no subscriptions found markup generated from the stripe_customer_portal_link shortcode action.

Usage

To apply to all forms:

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

To apply per form, add the form ID after the hook name:

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

Parameters

  • $markup (string) – The list markup.
  • $subscriptions (array) – Subscription information.
  • $form_id (integer) – Form ID related to subscriptions.

More information

See Gravity Forms Docs: gform_stripe_subscriptions_self_serve_markup

Examples

This example shows how to append a link to the markup in order to direct users to your create a subscription page when they have no subscription.

// Add a link to create a subscription if no subscriptions found
add_filter( 'gform_stripe_subscriptions_self_serve_markup', function( $markup, $subscriptions, $form_id ) {
    if ( empty( $subscriptions ) ) {
        $markup .= '<br><a href="{some_url}">Create a subscription now!</a>';
    }

    return $markup;
}, 10, 3 );

Add more examples as needed.

Placement
This code should be placed in the functions.php file of your active theme.

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

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