WordPress.org

Ready to get started?Download WordPress

Forums

Theme My Login
Remove Default Pages created on all multisites (3 posts)

  1. MYGM
    Member
    Posted 10 months ago #

    Hi, I am using theme my login on my wordpress network setup and I am currently trying to figure out how to remove or stop pages from being created for multisites. I dont want new users that create sites, to see the register, login, etc. pages that are created when making a new site.

    Also if possible I would like to find out how the plugin was able to create these default pages for all multisites, so that I can create my own custom pages that come with a new site.

    Thanks

    http://wordpress.org/plugins/theme-my-login/

  2. MYGM
    Member
    Posted 10 months ago #

    I figured out how to add default pages for multisites, but how do I remove the TML default pages?

    add_action('wpmu_new_blog', 'create_my_pages', 10, 2);
    
    function create_my_pages($blog_id, $user_id){
      switch_to_blog($blog_id);
    
      // not really need, new blogs shouldn't have any content
      if(get_page_by_title('About')) return;
    
      // create each page
      $page_id = wp_insert_post(array(
        'post_title'     => 'About',
        'post_name'      => 'about',
        'post_content'   => 'This is your about page',
        'post_status'    => 'publish',
        'post_author'    => $user_id, // or "1" (super-admin?)
        'post_type'      => 'page',
        'menu_order'     => 1,
        'comment_status' => 'closed',
        'ping_status'    => 'closed',
         // + see: http://codex.wordpress.org/Function_Reference/wp_insert_post
      ));  
    
      restore_current_blog();
    }
  3. verticalgrain
    Member
    Posted 9 months ago #

    To remove the "Sample Page" that WP creates when each new multisite site is created, add the following to your code block above. Add it just before the restore_current_blog() tag.

    // Find and delete the WP default 'Sample Page'
    $defaultPage = get_page_by_title( 'Sample Page' );
    wp_delete_post( $defaultPage->ID );

    This will delete the page with the title "Sample Page".

Reply

You must log in to post.

About this Plugin

About this Topic