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 manipulate a form's success message.
Usage
add_filter('frm_success_filter', 'change_my_confirmation_method', 10, 2);
Parameters
- $type (string) - possible return values are:
- 'message'
- 'redirect'
- 'page'
- $form (object)
Examples
Force Success Message on Update
This example will always show the success message when an entry is updated, even if the setting tells the form to redirect.
add_filter('frm_success_filter', 'change_my_confirmation_method', 10, 2);
function change_my_confirmation_method( $type, $form ) {
if ( $form->id == 5 && isset( $_POST ) && isset( $_POST['frm_action'] ) && $_POST['frm_action'] == 'update' ) { //change 5 to the ID of your form
$type = 'message';
}
return $type;
}
Force Success Message and Change Message
The example below will force a success message and set the message to "The form has been received."
add_filter('frm_success_filter', 'force_change_success_message', 10, 2);
function force_change_success_message( $type, $form ) {
if ( $form->id == 5 && isset( $_POST ) && isset( $_POST['frm_action'] )) { //change 5 to the ID of your form
$type = 'message';
$form->options['success_msg'] = "The form has been received.";
}
return $type;
}