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.
Use this hook to customize the "No Entries" message for a View.
Usage
add_filter( 'frm_no_entries_message', 'customize_no_entries_message', 10, 2); function customize_no_entries_message( $message, $args )
Parameters
- $message (string)
- $args (array), => [ 'display' (object) ]
Examples
Remove message
This function will completely remove the no entries message for a View. Just replace 1066 with the ID of your View.
add_filter( 'frm_no_entries_message', 'remove_no_entries_message', 10, 2);
function remove_no_entries_message( $message, $args ) {
if ( $args['display']->ID == 1066 ) {
$message = '';
}
return $message;
}
Remove surrounding div
This function will remove the no entries message div and class. Just replace 1066 with the ID of your View.
add_filter( 'frm_no_entries_message', 'remove_no_entries_message_div', 10, 2);
function remove_no_entries_message_div( $message, $args ) {
if ( $args['display']->ID == 1066 ) {
$message = str_replace( '<div class="frm_no_entries">', '', $message );
$message = substr( $message, 0, -6 );
}
return $message;
}
Display Specific Message Based on URL Parameter
This example will allow for a specific no entries message to be displayed if a user has filtered a View using a URL parameter, but no entries exist based on that filter. Replace 1378 with the ID of your View, and change the page URLs and messages as needed.
The URLs in this example are relative; therefore, if your URL is 'www.mysite.com/my-view/?status=pending', you would just use '/my-view/?status=pending'.
add_filter( 'frm_no_entries_message', 'remove_no_entries_message', 10, 2);
function remove_no_entries_message( $message, $args ) {
$host = $_SERVER['REQUEST_URI'];
if ( $args['display']->ID == 1378 ) {
if ($host == "/your-relative-url/?status=pending") {
$message = 'You have no pending entries.';
}
elseif ($host == "/your-relative-url/?status=incomplete") {
$message = 'You have no incomplete entries.';
}
}
return $message;
}