Gravity Forms + Stripe Cancel Account, Update Billing & More

Alternatives to Stripe + More for Gravity Forms

Gravity Forms for WordPress has an add-on for Stripe, and that add-on allows you to setup subscription payments for your customers.

However, there’s no way for a customer to go in and cancel their subscription or, if their payment fails, to update their payment plan. At least not right out of the box.

There’s a paid plugin out there called Gravity + More which I’ve used for years. I purchased it maybe three years ago and used it on a client’s site, a personal site of my own, and then was installing it on yet another site I’m developing that gives people access to their own travel blog, on a high-end WP Engine server, for a few bucks a month. The plugin just wasn’t working for me, and through the process of requesting support I discovered the following:

  1. Support just wasn’t there anymore. It took two days to receive my first reply, which was nothing more than a one liner of a question. The plugin’s author didn’t look into my issue at all, but blew it off for another 24 hour delay to responding. As I’m paying for the plugin, this was unacceptable to me. After a week, we were no closer to getting the problem solved and so I decided to go out and build this all on my own.
  2. The plugin doesn’t inform you of updates. Unlike every other WP plugin out there, when there’s an update for Gravity + More, there’s absolutely no way to know about it other than to write the author and ask if there’s an update. That’s just sloppy. I asked about this multiple times and was never given an answer.
  3. Because of this, the other sites that I used the plugin on were broken, unbeknownst to me. Both sites rarely have billing updates or cancellations – they just so happen to provide a subscription service few people ever want to cancel. I found this quite alarming, to be honest, and the plugin author, again, never acknowledged any of my questions on this.

For someone we’re entrusting our e-commerce gateway to, I just don’t think it’s cool for glaring issues like this to not only go unfixed, but for her to not even acknowledge them at all over multiple emails. That said, I can only imagine the plugin is working for other people…or at least the plugin’s author tells me it is. But it didn’t work for me across two different setups, and taking a week for her to even look at my code or site was just too long for a paid plugin.

So, without further ado, here’s the free walk through for those of you who don’t mind putting a little work in yourselves.

Setup Account Cancellations, Billing Updates & More with Gravity Forms

So, we’ll build it ourselves!

Install Gravity Forms

Firstly, you’ll need a copy of Gravity Forms. Buy it, install it, and then also get the User Registration and Stripe add-ons installed.

To do that, once Gravity Forms is installed, go to Forms > Add-Ons and find them in the list.

screenshot of these add-ons' installation screen
Install the User Registration and Stripe add-ons for Gravity Forms.

Next, setup a form that includes at least:

  1. Name or Username field.
  2. Email address.
  3. A Product and/or Total Field.
  4. A Credit Card field.
screenshot of form elements
An example of the fields we need.

Now that we’ve got our form fields setup, we can move onto the functionality.

User Registration

Go to Settings > User Registration for the form.

form settings dropdown

Add a new user registration feed on that screen.

  • Give it any Name.
  • Choose Create User.
  • For the User Settings, make sure to set a Username and Email field, and change the Role to whatever you want it to be (while Subscriber is fine, you may want to create something new like “Stripe Customer”, if you intend on giving them particular permissions after they pay).
  • Setup Stripe

    You’ll first need to go to Forms > Settings and then choose Stripe to get your various API keys setup, and then copy the web hook Gravity Forms provides back into your Stripe account. They walk you through how to do all of this, but you’ll of course need a account.

    screenshot of stripe settings in gravity forms main menu

    Next, back in our form, go to Settings > Stripe. Create a new feed and you’ll end up on a page like this:

    screenshot of stripe feeds settings page
    In this example, you can already see my existing feeds. You’ll just see a prompt to create a new feed if this is your first time.

    Create a new feed, you’ll get a page like this:

    stripe feed settings configuration page in WordPress
    This is where we’ll setup our Stripe feed.
    1. Set the Name to whatever you want to describe your feed to be.
    2. Set Transaction Type to Subscription.
    3. From the Recurring amount? field, choose either your form total or one of your product fields.
    4. Setup Billing Cycle, Setup Fee, and the Trial fields as you require. If you want a setup fee, you’ll need another product field in your form.
    5. Under Customer Information, set the Email field to your corresponding email form field from your Gravity Form.
    6. Description might be their name, or the product field. This will appear in Gravity Forms and so may be helpful to you in some other way not related to this tutorial.

    Great, save the settings!

    At this point, we can register users and charge them a recurring subscription. However, that’s all default functionality and not going to really serve the purpose. At this point, the customer can’t cancel or change their credit card information.

    Note that Stripe is really smart, though, and if a user’s credit card gets reissued, but keeps the same numbers (i.e., they just get a new expiration date), Stripe works with banks to auto-update this info, so the user doesn’t have to go in and update it again.

    Let’s continue to the magic!

    Saving Stripe Customer ID to a WordPress Custom User Meta Field

    We now need to associate our WordPress user with a Stripe Customer ID. In functions.php, add the following two snippets:

    add_action("gform_user_registered", "autologin", 10, 4);
    function autologin($user_id, $config, $entry, $password) {
    wp_set_auth_cookie($user_id, false, '');
    // save Stripe customer ID to user meta data
    add_action( 'gform_stripe_customer_after_create', 'save_stripe_customer_id' );
    function save_stripe_customer_id( $customer ) {
    if ( is_user_logged_in () ) {
    update_user_meta( get_current_user_id(), '_stripe_customer_id', $customer->id );

    The first code snippet there automatically logs the user in after they’ve registered, and the second saves their Stripe ID as user meta to their account. Now, we have the user’s WP account tied directly to their Stripe ID. Note that if you didn’t do this right from the beginning, i.e. you’ve already got users, then you’ll need to go in and manually add these. Or maybe you could write a script, but I won’t be covering that here. Just find the user by their email address in Stripe, and create a custom meta field for them with the key of _stripe_customer_id and the value as their Stripe Customer ID.

    Updating Billing Information

    Next, let’s create a form so that they can update their billing info.

    This form will need the following fields:

    1. Credit Card.
    2. Email, if you want to send notifications.
    3. Product, which can be set to anything above 50 cents. We won’t actually be charging them anything, this is to put a “hold” / authorization on their account, allowing us to change their credit card info, but doesn’t actually capture / charge the amount.

    Now go to Settings > Stripe for this form, and we’ll create a new feed.

    screenshot of stripe settings
    These settings are important! See below.
    1. Important! Name the new setting Update Credit Card. You can name this whatever you want, really, but you need to remember the name exactly as we’ll use it later.
    2. Transaction type should be Products and Services this time around.
    3. Payment Amount needs to be the product field we setup with our $0.50 or more amount.

    Save the form.

    Back in functions.php, we need a bit more code now.

    add_filter( 'gform_stripe_customer_id', 'get_stripe_customer_id' );
    function get_stripe_customer_id( $customer_id ) {
    if ( is_user_logged_in () ) {
    $customer_id = get_user_meta( get_current_user_id(), '_stripe_customer_id', true );
    return $customer_id;

    add_filter( 'gform_stripe_charge_authorization_only', 'stripe_charge_authorization_only', 10, 2 );
    function stripe_charge_authorization_only( $authorization_only, $feed ) {
    $feed_name = rgars( $feed, 'meta/feedName' );
    if ( $feed_name == 'Update Credit Card' ) {
    return true;
    return $authorization_only;

    What are we doing?

    First, we get the user’s Stripe ID, then we configure it so that our “Update Credit Card” feed, that we just created, only changes their credit card info…it doesn’t actually charge them. Note the highlighted bit of text in the code snippet above, which is where we use our feed name that I told you to remember.

    You’re getting there!

    To test at this point, go ahead and complete both forms. After you complete the form that registers the user, look in Stripe at the Customers tab and find the new entry. Then submit the billing update form and look again, the credit card number will have changed (be sure to use a different card the second time).

    Now you can configure Stripe to send them a notification if there card gets cancelled, too, linking back to this form on your site!

    Allow Customers to Cancel

    This part is super easy, just add the following to your functions.php:

    add_action( 'gform_subscription_canceled', 'downgrade_user_role', 10, 2 );
    function downgrade_user_role( $entry, $feed ) {
    if ( rgar( $feed, 'addon_slug' ) != 'gravityformspaypal' && function_exists( 'gf_user_registration' ) ) {
    $user = gf_user_registration()->get_user_by_entry_id( $entry['id'] );
    if ( ! empty( $user ) && ! is_wp_error( $user ) ) {
    $user->set_role( 'subscriber' );

    You could perform any function here really, but in this case we’re (see the highlighted section), changing their role to Subscriber. That’s why I stated you may want to create a new role in the form settings early on in this section (where you setup the User Registration feed). That way, they’d be downgraded but not cancelled, and you could then provide additional forms or manual interactions where you upgrade them again if they start their Stripe subscription again.

    Helpful? Would love to see what you do with this in the comments!

    Want support? Unlike Stripe + More, I’m not charging a dime for this little tutorial, and likewise, I’m not providing free support either. If you’d like to hire me, feel free to get in touch and we’ll see what we can do.

    Up Next: How to fix "A value for the logo field is required" via Google's Rich Snippets Tool