Hide pages from wordpress admin on creation

I am attempting to develop a new bit of software for my web dev company that creates all the pages (that should not be touched by the customer) such as login/create new account/checkout etc etc.

But then on creation also hides them from certain Admins (well all admins as realistically they should never be changed and if they are changed will be by a developer who knows the system inside and out and could change via SQL etc.

I have read (How to hide pages from wordpress admin side) but this means modifying functions.php which i really don’t want to do as each functions.php can be different on my customer websites and this tool im creating will be a run script and then complete type of script:

Here is what i am using to create a page:


ini_set('display_errors', 1);

define('WP_USE_THEMES', false);
//require( dirname( _FILE_ ) . '/wp-blog-header.php' );
require('wp-blog-header.php' );

// Create post object
$my_post = array(
  'post_type' => 'page',
  'post_parent' => '',
  'post_title'    => "Test Checkout Page",//wp_strip_all_tags( $_POST['post_title'] ),
  'post_name' => 'mason-test',
  'post_content'  => "<h1>hello world this is a test checkout</h1><p>This is a new paragraph :D</p>",// $_POST['post_content'],
  'post_status'   => 'publish',
  'post_author'   => 1,
  'post_category' => array( 1,2 )

// Insert the post into the database
$post_id = wp_insert_post( $my_post );
// Save the permalink
$permalink = get_permalink( $post_id );

echo "$permalink";

Is there any way i can hide these created pages from the admin when i say hide i mean, hide the ability for them to edit it or the ability for them to search/find it on the pages page on wordpress.

Ofcourse they can see it on the front end etc.

Read more here: Hide pages from wordpress admin on creation

Leave a Reply

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