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 make changes to the rendered form content before it is returned by the form shortcode.
Usage
add_filter( 'frm_filter_final_form', 'filter_hide_this' ); function filter_hide_this( $form )
Parameters
- $form (string)
Examples
Use shortcode throughout HTML in form
You can use this this example code to place opening and closing shortcode tags to span throughout HTML fields in the form. This particular example shows how to use the shortcode for the Hide This plugin.
add_filter( 'frm_filter_final_form', 'filter_hide_this' );
function filter_hide_this( $form ) {
global $shortcode_tags;
$original_shortcodes = $shortcode_tags;
$limited_shortcodes = array( 'hidethis' => $shortcode_tags['hidethis'] );
$shortcode_tags = $limited_shortcodes;
$form = do_shortcode( $form );
$shortcode_tags = $original_shortcodes;
return $form;
}
add_filter( 'frm_do_html_shortcodes', '__return_false' );
Minimize the form without the shortcode
The easiest way to minimize the form HTML is by adding minimize=1 to your [formidable] shortcode. But if every form on your site needs to be minimized, you can strip out the white space before it can be converted to <p> or <br/> tags with this:
add_filter( 'frm_filter_final_form', 'auto_minimize_forms' );
function auto_minimize_forms( $form ) {
$form = str_replace( array( "rn", "r", "n", "t", ' ' ), '', $form );
return $form;
}
Change a word
Use this code example to change a word or phrase in a form to another word or phrase. For example, you can change the word "Edit" that appears in the Summary field to "Revise."
To use the code example, replace "Edit" with the word or phrase you want to change and "Revise" with the word or phrase to which you want to change it.
Note: this code example will change all occurrences of the word or phrase in the form.
add_filter( 'frm_filter_final_form', 'change_edit_label' );
function change_edit_label( $form ){
$form = str_replace( 'Edit', 'Revise', $form );
return $form;
}
Remove icon and instruction
Use this code example to remove the SVG that appears with the press Enter text, as well as the Shift+Tab instructions at the bottom of the page in a Conversational form.
add_filter( 'frm_filter_final_form', 'remove_conversational_html', 15 );
function remove_conversational_html( $html ) {
// Remove enter icons
$html = preg_replace( '/<svg(.*?)d="M15.3 6c0 .7-.3 1.2-.7 1.7a2.2 2.2 0 0 1-1.7.7H7.4v2.3L.6 7.5l6.8-3.2v2.3H12c.3 0 .6-.1.8-.3.3-.2.4-.5.4-.8V.7h2V6Z"(.*?)\/><\/svg>/', '', $html, 2 );
// Remove the "Shift+Tab" instruction
$html = preg_replace( '/<div class="frm-key-instructions">(.*?)<\/div>/', '', $html, 1 );
return $html;
}
Skip start page
Use this code to skip the first page with the start button in a Conversational form.
add_filter('frm_filter_final_form', 'skip_start_page', 15);
function skip_start_page( $form ) {
$form = str_replace(
'class="frm_active_chat_field frm_chat_start_page"',
'style="display: none;" class="frm_active_chat_field frm_chat_start_page"',
$form
);
return $form;
}