Created
August 21, 2014 19:40
-
-
Save zachskaggs/f65c21cab784b467311a to your computer and use it in GitHub Desktop.
Ninja Forms Append 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
function customnf_success_msg( $content ) { | |
global $ninja_forms_processing; | |
if( ! isset( $ninja_forms_processing ) ) | |
return $content; | |
$success = ''; | |
if( $success = $ninja_forms_processing->get_all_success_msgs() ) { | |
foreach( $success AS $id => $msg ) { | |
$success .= $msg . '<br />'; | |
} | |
} | |
$error = ''; | |
if( $error = $ninja_forms_processing->get_all_errors() ) { | |
foreach( $error AS $id => $msg ) { | |
$error .= $msg . '<br />'; | |
} | |
} | |
if( !empty( $success ) OR !empty( $error ) ) { | |
$new_content = '<div class="customnf-msgs">'; | |
if ( $success ) { | |
$new_content .= $success; | |
} | |
if ( $error ) { | |
$new_content .= $error; | |
} | |
$new_content .= '</div>'; | |
$content = $new_content . $content; | |
} | |
return $content; | |
} | |
add_filter( 'the_content', 'customnf_success_msg' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment