Hey all,
I've setup a static page as my homepage. The project has a number of editors that can add, edit and delete pages but I want to make sure they can't delete the page chosen as the homepage. Is that possible?
Thanks
tonto
Hey all,
I've setup a static page as my homepage. The project has a number of editors that can add, edit and delete pages but I want to make sure they can't delete the page chosen as the homepage. Is that possible?
Thanks
tonto
Untested, but maybe something like..
add_action('delete_post','no_remove_front_page');
function no_remove_front_page( $_the_post_id ) {
global $post;
if ( 'page' != $post->post_type)
return;
if ( get_option('page_on_front') == $_the_post_id )
// If the ID matches the front page ID, kill the delete post action.
wp_die('Cannot delete the front page, sorry!');
return;
}
Would need to be tested though..
Cool, thanks for that! I'll try it out.
That worked perfectly, I also added in another test for a static posts page. Thanks again!
add_action('trash_post','no_remove_req_page');
function no_remove_req_page( $_the_post_id ) {
global $post;
if ( 'page' != $post->post_type)
return;
if ( get_option('page_on_front') == $_the_post_id )
// If the ID matches the front page ID, kill the delete post action.
wp_die('Cannot delete the front page, sorry!');
elseif(get_option('page_for_posts') == $_the_post_id)
wp_die('Cannot delete the news page, sorry!');
return;
}
Happy i could help... :)
This topic has been closed to new replies.