Hook for when EOT is changed via payment?

Please can somebody help with this.

I cannot find anything relevant for this. add_action profile_update works when changing EOT manually which I sometimes have to do for users. Unfortunately it doesn’t work when EOT is changed via payment.

This could be using any one of three payment gateways so cannot be a specific hook (e.g., just for Paypal).
Also this is not a new subscription or registration, just a renewal of expired membership, or an extension of existing EOT.

Is there a hook which I could use for when EOT changes via (any) payment gateway?

(Also I checked the API Notifications but there doesn’t seem to be a variable which says when the EOT date is)

Thank you

If it’s a renewal of a subscription, an EOT is not set at that time. It will only be set if it’s a renewal of a Buy Now transaction.

I think they’re all “buy now” at the moment on my site so this might be feasible!

Also I cannot find any hooks for Stripe in the documentation which seemed a bit strange. All the other payment gateways except for Stripe. Else I would have made a function for Stripe and also one for Paypal. So I’m hoping there is a generic catch all hook after any payment or EOT change.

Please do you know which hook I might have any chance with?

Try this for a hook: ws_plugin__s2member_during_stripe_notify_during_subscr_payment

Thanks but unfortunately it doesn’t seem to be working. I don’t think such a hook exists, can’t find anything about it on the web.

Do you or anyone know of other hooks or a way to have the EOT data duplicated across 2 rows when it changes/is created?

If somebody could hack s2member or wordpress to do this, I will pay. I’m getting desperate!

I think you need to post your code. It might not be the hook, but how you are making use of the hook, that’s the problem.

The setup is 2 sites sharing the same users via the custom users and usermeta tables, hence the SQL code in the function. Unfortunately each site has it’s own rows of the metadata so both rows need to be in sync else user won’t have same EOT across both sites :frowning:

add_action( 'ws_plugin__s2member_during_stripe_notify_during_subscr_payment', 'duplicate_meta');

function duplicate_meta() {
        
			// site 1 prefix
           $prefix_1 = 'vp_';
          
           // Site 2 prefix
           $prefix_2 = 'tv_';
          
           $my_eot = get_user_meta( $user_id, 'vp_s2member_auto_eot_time', true );
       
    // connect to the other database              
           $user="tv";
           $password="mypassword";
           $database="tv";        
           $host="localhost";   
           $con=mysqli_connect($host,$user,$password,$database);
          
           $update= "UPDATE tv_usermeta SET meta_value= '".$my_eot."' WHERE user_id=".$user_id." AND meta_key='tv_s2member_auto_eot_time'" ;
          
           mysqli_query($con,$update) ;
}

The above code works when modified to run on manual profile updates such as:

add_action( 'profile_update', 'duplicate_meta', 10, 2);

function duplicate_meta($user_id, $old_user_data) {

and it updates the EOT across both table rows for the 2 sites. But profile_update is only for changes via the front end.

Also as you’ve probably seen on another similar topic, I have the user roles synchronised across both sites using the kinsta_share_users plugin.

So all that’s left is the EOT to update across 2 table rows when people use a Buy it Now on Stripe.

You can run this function not by a hook, but by “Dashboard -> s2Member -> API / Notifications -> Payment Notifications” instead. There is a link that explains how to do.

Thanks. I looked at this but don’t think it is easy for my current PHP knowledge.

I have messaged you, maybe we can discuss your services. Thank you

Paul,

Just a thought.
Maybe you can use so called web hooks from your payment provider to be notified about EOT.
Payment providers send all kinds of info (notifications) to your website and via web hooks you can intercept these notifications, process them and take the appropriate action(s) such as emailing a client that a payment is due, or that a subscription is upgraded or downgraded.
Check with the payment provider you work with to see is possible.
Stripe, for example, has very good documentation on how to use web hooks: https://stripe.com/docs/webhooks

Thanks for the reply. Yes perhaps I will have to take that route but it is timely as I am not very experienced with APIs and PHP.

I think for the time it would take me to set it up, might be worth me paying for someone to help.

Regards