Skip to content

Instantly share code, notes, and snippets.

@zachskaggs
Created August 21, 2014 19:40
Show Gist options
  • Save zachskaggs/f65c21cab784b467311a to your computer and use it in GitHub Desktop.
Save zachskaggs/f65c21cab784b467311a to your computer and use it in GitHub Desktop.
Ninja Forms Append Error Messages
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