Change the Delete Entry mode from "Delete" to "Trash"

The entry is permanently deleted when deleting it in GravityView ( see more here). If you want to have the entry moved to the trash instead, please use the code snippet below:

add_filter( 'gravityview/delete-entry/mode', 'gk_delete_entry_mode_return_trash' );

function gk_delete_entry_mode_return_trash() {
	return 'trash';
}

How to only target a specific View

If you wish to apply this setting to a specific View only instead of changing the mode for all Views, then use the code below by making sure to replace "123" with the ID of your View:

add_filter( 'gravityview/delete-entry/mode', 'gk_delete_entry_mode_return_trash' );

function gk_delete_entry_mode_return_trash() {
	$view = gravityview()->request->is_view();
	if ( $view ) {
		$view_id = $view->settings->get( 'id' ); 
		if( $view_id == 123 ){ //Change 123 to your View ID
			return 'trash';
		}
	}
	return 'delete';
}

How this code works

The plugin uses the gravityview/delete-entry/mode filter to return a value of trash instead of the default, delete.

See how to add this code snippet to your website: Where to put code samples.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us