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.
Make changes to the content used in the exported CSV.
Usage
add_filter( 'frm_export_content', 'change_exported_cell' ); function change_exported_cell( $content )
Parameters
- $content (string) - The value to be exported.
Examples
Remove "View more" link
Exporting views includes all of the content. This example removes a "View more" since it isn't needed in the view.
add_filter( 'frm_export_content', 'change_exported_cell' );
function change_exported_cell( $content ) {
$content = str_replace( 'View more', ' ', $content );
return $content;
}
Replace ampersand HTML in CSV export
Use the code below to replace the ampersand HTML in exported field.
add_filter( 'frm_export_content', 'replace_ampersand' );
function replace_ampersand( $content ) {
$content = str_replace( 'amp;', ' ', $content );
return $content;
}
Add apostrophe for phone numbers
Use this code snippet to add the apostrophe if the value looks like anything but a number with some periods or dashes. If you have removed '+' from the risky characters list, this will add the apostrophe for potentially risky cells but removes the apostrophe before the '+' sign for phone numbers.
add_filter(
'frm_export_content',
function( $cell ) {
if ( '+' === substr( $cell, 0, 1 ) && ! cell_is_phone_number( $cell ) ) {
return "'" . $cell;
}
return $cell;
}
);
function cell_is_phone_number( $cell ) {
$substring = substr( $cell, 1 );
$substring = str_replace( array( '-', '.' ), array( '', '' ), $substring );
return is_numeric( $substring );
}