Ninja Forms AWeber: Suppress Errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Submit form even if user is already subscribed to AWeber List | |
* | |
* @param $msg - current message from Ninja Forms for AWeber | |
* @param $error_code - null, placeholder for when AWeber gets error codes | |
* @param $error_message - original message from AWeber | |
* @param $subscriber - array of info about the subscriber submitted via form | |
* -- nb the form's ID can be found in $subscriber['form_id'] | |
* @param $list_id the list ID | |
*/ | |
function nf_aweber_ignore_specific_error( $show, $error_code, $error_message, $subscriber, $list_id ){ | |
if( strpos( $error_message, 'Subscriber already subscribed' ) !== false ){ | |
$show = false; | |
} | |
return $show; | |
} | |
add_filter( "ninja_forms_aweber_show_errors", "nf_aweber_ignore_specific_error", 10, 5 ); | |
/* | |
* Suppress ALL errors on form id=5 | |
*/ | |
function nf_aweber_suppress_errors_for_form( $show, $error_message, $error_code, $subscriber, $list_id ){ | |
if( isset( $subscriber['form_id'] ) && 5 == intval( $subscriber['form_id'] ) ){ | |
$show = false; | |
} | |
return $show; | |
} | |
add_filter( 'ninja_forms_aweber_show_errors', 'nf_aweber_suppress_errors_for_form', 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment