Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
Last active December 24, 2015 18:40
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/e5439331521a57dee49c to your computer and use it in GitHub Desktop.
Save helgatheviking/e5439331521a57dee49c to your computer and use it in GitHub Desktop.
Ninja Forms AWeber: Custom error messages
/*
* Custom AWeber Error Messages
*
* @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_change_aweber_error( $new_message, $error_code, $error_message, $subscriber, $list_id ){
switch( $error_message ){
case strpos( $error_message, 'Consumer key is invalid' ) !== false :
$new_message = __( "You aren't connected!", 'your-text-domain' );
break;
case strpos( $error_message, 'Subscriber already subscribed' ) !== false :
$new_message = __( "Dude, you're already on this list.", 'your-text-domain' );
break;
case strpos( $error_message, 'Email address blocked' ) !== false :
$new_message = __( "We can't accept that email adddress", 'your-text-domain' );
break;
default:
$new_message = __( "Something broke", 'your-text-domain' );
return $new_message;
}
add_filter( 'ninja_forms_aweber_subscribe_error_message', 'nf_change_aweber_error', 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment