Skip to content

Instantly share code, notes, and snippets.

@wpmudev-sls
Last active January 23, 2025 08:48
Show Gist options
  • Save wpmudev-sls/204a50fe6262fa80909fff0a7c327301 to your computer and use it in GitHub Desktop.
Save wpmudev-sls/204a50fe6262fa80909fff0a7c327301 to your computer and use it in GitHub Desktop.
[Forminator Pro] - Fix missing user agent in stripe subscription
<?php
/**
* Plugin Name: [Forminator Pro] Fix stripe subscription missing user agent
* Description: Fix stripe subscription missing user agent.
* Author: Prashant @ WPMUDEV
* Task: SLS-6775
* Author URI: https://premium.wpmudev.org
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Fix stripe subscription missing user agent.
*
* @param array $data Customer acceptance data.
*/
function wpmudev_fix_user_agent_stripe( $data ) {
if ( empty( $data['mandate_data']['customer_acceptance']['online']['user_agent'] ) && ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
$data['mandate_data']['customer_acceptance']['online']['user_agent'] = esc_html( sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) );
}
return $data;
}
add_filter( 'forminator_stripe_subscription_payment_confirmation_args', 'wpmudev_fix_user_agent_stripe' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment