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.
Adjust the standard value shown in the email, entries page, or views. The name of the hook will changed based on the type of field being displayed.
Usage
add_filter( 'frm_display_text_value_custom', 'adjust_text_value', 10, 2 ); function adjust_text_value( $value, $args ) {
Parameters
- $value (string or array) - The value to be displayed
- $args (array)
- $args['field'] (object) - The field being displayed
- $args['entry'] (object) - The entry that is being displayed
Examples
Format an email address
Switch a displayed email address to a mailto link.
add_filter( 'frm_display_email_value_custom', 'frm_email_val', 15, 2 );
function frm_email_val( $value, $atts ) {
if ( $atts['field']->id == 500 ) { // Change 500 to the ID of your email field
$value = '<a href="mailto:' . $value . '">' . $value . '</a>'; //change the value here
}
return $value;
}
Filter page break fields
Use this example to change the default <br /><br /> to a Page # string that counts up with each page break (starting from page 2 since there is no page break rendered at the start).
$page_number = 1;
// Reset page name each time an entry shortcode begins.
add_filter(
'frm_show_entry_defaults',
function( $defaults ) use ( &$page_number ) {
$page_number = 1;
return $defaults;
}
);
add_filter(
'frm_display_break_value_custom',
function( $value, $args ) use ( &$page_number ) {
$target_form_id = 464; // Change 464 with your form ID
if ( $target_form_id !== (int) $args['field']->form_id ) {
return $value;
}
$is_plain_text = isset( $args['atts'] ) && ! empty( $args['atts']['plain_text'] );
$value = 'Page ' . ( ++$page_number );
if ( ! $is_plain_text ) {
$value = '<b>' . $value . '</b>';
}
return $value;
},
10,
2
);