how to get data from a plugin using a custom action?
-
Hi Ironikus!
I want to get user payment data from a WordPress plugin via a custom Webhook action
Plugin code:
add_action( 'subscribe_success_pay', 'opt_payment', 10 ); function opt_payment( $payData ) { if ( $payData->pay_type != 'subscribe-pay' ) return false; $baggage = $payData->baggage_data; $tariff = opt_get_tariff( $baggage->tariff_id ); $tariff_price = opt_get_tariff_price( $baggage->tariff_id, $payData->user_id ); if ( $tariff_price != $payData->pay_summ ) return false; do_action( 'opt_pre_payment_access', $payData, $tariff ); $payment_id = opt_add_payment( array( 'user_id' => $payData->user_id, 'account_name' => opt_get_account_field( $tariff->account_id, 'account_name' ), 'tariff_price' => $tariff_price, 'access_time' => $tariff->access_time ) ); $access_id = opt_update_user_access( $payData->user_id, $tariff->account_id, $tariff->access_time ); do_action( 'opt_payment_access', $payment_id, $access_id, $baggage->tariff_id ); }
I make a filter and a function according to your documentation and insert it into functions.php
add_filter( 'wpwhpro/run/actions/custom_action/return_args', 'wpwh_fire_my_custom_logic', 10, 3 ); function wpwh_fire_my_custom_logic( $return_args, $identifier, $response_body ){ if( $identifier !== 'subscribe' ){ $return_args = array( 'user_id' => $payData->user_id, 'account_name' => wau_get_account_field( $tariff->account_id, 'account_name' ), 'tariff_price' => $tariff_price, 'access_time' => $tariff->access_time ); } return $return_args; }
But after the user pays, the webhook does not work. How to get data from a plugin into your function?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘how to get data from a plugin using a custom action?’ is closed to new replies.