Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
Created July 30, 2015 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helgatheviking/b3c467f3b7d1cc687ce9 to your computer and use it in GitHub Desktop.
Save helgatheviking/b3c467f3b7d1cc687ce9 to your computer and use it in GitHub Desktop.
Ninja Forms AWeber: Suppress Errors
/*
* 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