gform_post_fail_subscription_payment

gform_post_fail_subscription_payment

DescriptionUsageParametersExamples1. Basic Usage2. Update User RoleSource Code

Description
Triggered after an existing subscription payment fails.
Usage
1add_action( 'gform_post_fail_subscription_payment', 'my_function', 10, 2 );

Parameters

$entry Entry Object
The entry object that was created,

$action array
The action that occurred within the subscription payment. Contains further information about the subscription.
12345678910$action = array(    'type'             => '',    'amount'           => '',    'transaction_type' => '',    'transaction_id'   => '',    'subscription_id'  => '',    'entry_id'         => '',    'payment_status'   => '',    'note'             => '',);

Examples
1. Basic Usage
1234function my_function() {    //Do something here}add_action( 'gform_post_fail_subscription_payment', 'my_function', 10, 2 );
2. Update User Role
1234567891011add_action( 'gform_post_fail_subscription_payment', 'update_user_role' );function update_user_role( $entry ) {    if ( function_exists( 'gf_user_registration' ) ) {        // use WP_User to change role - https://developer.wordpress.org/reference/classes/wp_user/        $user = gf_user_registration()->get_user_by_entry_id( $entry['id'] );        if ( is_object( $user ) ) {            $user->remove_role( 'role_one' );            $user->add_role( 'role_two' );        }    }}
Source Code
1do_action( 'gform_post_fail_subscription_payment', $entry, $action );
This action hook is located in GFPaymentAddOn::fail_subscription_payment() in includes/addon/class-gf-payment-addon.php.

發表回覆

您的郵箱地址不會被公開。 必填項已用 * 標註