This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This hook can be used to replace the form success/update message with a custom success/update message.
Usage
add_filter( 'frm_main_feedback', 'frm_main_feedback', 20, 3 ); function frm_main_feedback( $message, $form, $entry_id )
Parameters
- $message (string)
- $form (object)
- $entry_id (integer)
Examples
Remove success message
Use the code example below to remove the success message for a specific form.
add_filter( 'frm_main_feedback', 'remove_success_message', 9, 2 );
function remove_success_message( $message, $form ) {
$target_form_id = 624; // Replace 624 with the ID of your form
if ( $target_form_id === (int) $form->id ) {
// Remove success message for target form ID
$message = '';
}
return $message;
}
Use a custom class for the success message
You can use this example to replace 'frm_message' with your own custom class.
add_filter( 'frm_main_feedback', 'frm_custom_feedback_class', 20, 3 );
function frm_custom_feedback_class( $message, $form, $entry_id ) {
if ( $form->id == 125 ) { //Replace with the ID of your form
$message = str_replace('frm_message', 'my_custom_class', $message );
}
return $message;
}
Add form HTML in Outcome Quiz
Use this code example to display a form in the Outcome Quiz results. It will check the message body if a specific word appears in the result. For example:
- If the word Lion appears in the result, the form 434 will be included after the message.
- If the word Panda appears instead, then the form 436 is added to the message.
add_filter('frm_main_feedback', 'add_form_outcome_quiz' , 11, 3);
function add_form_outcome_quiz( $message, $form, $entry_id ) {
$target_form_id = 435; //Replace 435 with the ID of the form with the outcome quiz
if ( $target_form_id !== (int) $form->id ) {
return $message;
}
$form_id_by_result = array(
'Lion' => 434, //Replace 434 with the ID of the form to be displayed
'Panda' => 436, //Replace 436 with the ID of a form to be displayed
);
foreach ( $form_id_by_result as $result => $form_id ) {
if ( false !== strpos( $message, $result ) ) {
$message .= do_shortcode( '[formidable id=' . $form_id . ']' );
break;
}
}
return $message;
}