Last active
December 24, 2015 18:40
-
-
Save helgatheviking/e5439331521a57dee49c to your computer and use it in GitHub Desktop.
Ninja Forms AWeber: Custom error messages
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
/* | |
* 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