Stripe, User Registration, and free trial subscriptions

Hi
I am in an email discussion with Samuel Aguilera about this but I want this solved yesterday and I cannot find much previous talk of this on the internet.

I have a form linked to a Stripe feed, for a subscription product, and a user registration update user feed. All works fine.

However, If I enable “delay user registration feed until payment received” then it all falls apart. The update user feed will not fire - presuably because no money has been received. This causes chaos because the role never gets upgraded - i assume it would eventually when the first payment is taken.

Surely this cant just be me strugging with this?? At the minute I have to disable the feed delay, meaning users are getting the role upgrade as soon as submitting the form - even without a stripe payment!

Anyone got a workaround ?!

Ive been working hard on this. the integration between stripe and user registration add-ons is clearly flawed in its methodology when it comes to free trial subscriptions. you cannot get a role upgrade to take place after a subscription is created for a free trial, because the “delay user reg feed until payment received” does not fire. the alternative is disabling this feature, but then anyone can get a role upgrade even if they dont go through with the stripe subscription.

I have come up with this as a stopgap solution.

it uses gform_post_subscription_started to manually check what was subscribed to, make sure it was successful, and then change the user role.

add_action( 'gform_post_subscription_started', 'set_user_role_post_subs', 10, 2 );


function set_user_role_post_subs ( $entry, $subscription ) {
   
// get the subscriber details and role from the user who submitted the order form
$subscriber = get_user_by('id',$entry['created_by']);
$user_roles = $subscriber->roles;
    

//if stripe is success
if ($subscription['is_success'] == 1) {
    
  //remove all possbible user roles currently allocated to the customer

     if ( in_array( "subscriber", $user_roles ) ) {
          $subscriber->remove_role( 'subscriber' );
     }
        
       if ( in_array( "group_subscriber", $user_roles ) ) {
          $subscriber->remove_role( 'group_subscriber' );
     }

     //assign new role depending on subscription product  name

     if ($entry['4.1'] == 'Individual Subscription') {
          $subscriber->set_role( 'subscriber' );
          }

     if ($entry['4.1'] == 'Group Subscription') {
     $subscriber->set_role( 'group_subscriber' );
          }

}
        
    return $entry;
}

field 4.1 is the form field with the product.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.