Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wpmudev-sls/2c60edf826cc3f2d03a47b0891b81676 to your computer and use it in GitHub Desktop.
Save wpmudev-sls/2c60edf826cc3f2d03a47b0891b81676 to your computer and use it in GitHub Desktop.
[Forminator Pro] - DIfferent redirect based on integration (Aweber) submission result
<?php
/**
* Plugin Name: [Forminator Pro] DIfferent redirect based on Aweber integration submission result
* Description: DIfferent redirect based on Aweber integration submission result.
* Author: Prashant @ WPMUDEV
* Task: SLS-6184
* Author URI: https://premium.wpmudev.org
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
add_filter( 'forminator_addon_form_aweber_entry_fields', 'wpmudev_redirect_on_aweber_failure', 10, 5 );
function wpmudev_redirect_on_aweber_failure( $entry_fields, $form_id, $submitted_data, $form_settings_instance, $current_entry_fields ) {
if ( 2960 !== intval( $form_id ) ) { // Please change the form ID.
return $entry_fields;
}
if ( ! $entry_fields[0]['value']['is_sent'] ) { // Checks if aweber failed.
$GLOBALS['aweber_redirect_url'] = 'your_url_here'; // Please change the URL.
}
return $data;
}
add_filter( 'forminator_form_submit_response', 'wpmudev_aweber_response_url_redirect', 20, 2 );
add_filter( 'forminator_form_ajax_submit_response', 'wpmudev_aweber_response_url_redirect', 20, 2 );
function wpmudev_aweber_response_url_redirect( $response, $form_id ) {
if ( 2960 !== intval( $form_id ) ) { // Please change the form ID.
return $response;
}
if ( ! empty( $response['url'] ) && ! empty( $GLOBALS['aweber_redirect_url'] ) ) {
$response['url'] = $GLOBALS['aweber_redirect_url'];
unset( $GLOBALS['aweber_redirect_url'] );
}
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment