Restrict page post delete

0
242

Restrict Category data delete

add_action( ‘delete_term_taxonomy’, ‘wpse_70758_del_tax’, 10, 1 );

function wpse_70758_del_tax( $tt_id )
{ // 48, 43, 87, 141, 147, 76, 129, 142, 148
$undeletable = array( ‘saloon-services’,
‘wedding-planner’);
$term = get_term_by( ‘id’, $tt_id, ‘item_amenities’ );

if( in_array( $term->slug, $undeletable ) )
wp_die( “Sorry! you don’t have permission to delete these category. Go Back » <a href=”.$_SERVER[‘HTTP_REFERER’].”>Click Here</a> ” );
}

Restrict page post delete

function restrict_post_deletion($post_ID){ $user = get_current_user_id(); $restricted_users = array(1); $restricted_pages = array(2,7,9,11,13,15,53,43,46,51,63,70,72,74,76,103,202); if(in_array($user, $restricted_users) && in_array($post_ID, $restricted_pages)){ echo “You are not authorized to delete this page.”; exit; } } add_action(‘trash_post’, ‘restrict_post_deletion’, 10, 1); add_action(‘delete_post’, ‘restrict_post_deletion’, 10, 1); add_action(‘wp_trash_post’, ‘restrict_post_deletion’, 10, 1); add_action(‘before_delete_post’, ‘restrict_post_deletion’, 10, 1); In this pass page id $restricted_pages = array(2,7,9,11,13,15,53,43,46,51,63,70,72,74,76,103,202); echo “You are not authorized to delete this page. Go Back &raquo; <a href=”.$_SERVER[‘HTTP_REFERER’].”>Click Here</a>”; ye msg update ker digiyega iski jagha echo “You are not authorized to delete this page.”;