Leveraging AI to Supercharge Your WordPress Business Website
In today’s competitive digital landscape, every business website needs an edge to...
9.Aug.2022 | Code Snippets, Wordpress
To stop any page from being deleted by any user role, including admins, add the following code to your functions.php file.
Update the $post_id variable to the ID of the page or post you want to protect from deletion.
function prevent_views($allcaps, $caps, $args) {
$post_id = 6293;
if ( isset( $args[0] ) && isset( $args[2] ) && $args[2] == $post_id && $args[0] == 'delete_post' ) {
$allcaps[ $caps[0] ] = false;
}
return $allcaps;
}
add_filter ('user_has_cap', 'prevent_views', 10, 3);
Coding Tips, PHP, Wordpress, WordPress Tips
Share
In today’s competitive digital landscape, every business website needs an edge to...
WordPress has come a long way since its humble beginnings in 2003....
In the ever-evolving landscape of website development, staying ahead of the curve...
Commonly asked eCommerce questions: A nice little bit of information about #PCIDSS for @WooCommerce - http://goo.gl/BSK6Ba Lee Harris - Twitter...
This snippet of PHP can come in handy for removing the empty spaces in a string. Here is it being...
Being a freelance web designer, I’m lucky enough to be able to work anywhere in the country… as long as...