Remove Trash / Delete option for Custom Post Type / Taxonomy

I’ve created a custom post type prj, and I need to disable move to trash option by any user role! Same goes with a taxonomy org associated with the same post type.

Here is the code I’ve come up with so far .. but it only hides the option from the admin menu rather than disabling the capability from the user roles!

//Disabling Trash Option for Project
add_filter( ‘post_row_actions’, ‘remove_row_actions_post’, 10, 1 );
function remove_row_actions_post( $actions ) {
if( get_post_type() === ‘prj’ ) {
unset( $actions[‘clone’] );
unset( $actions[‘trash’] );
return $actions;
}
}

Read more here:: Remove Trash / Delete option for Custom Post Type / Taxonomy

Leave a Reply

Your email address will not be published. Required fields are marked *