WordPress.org

Ready to get started?Download WordPress

Forums

Auto page creation with template moved (1 post)

  1. dclaughton
    Member
    Posted 3 years ago #

    Just realised I put this in the wrong forum so this is a repost. I've got this working for an auto page creation in a plugin when a new user registers. It seems to work fine and it does what it supposed to ie. creates a page and sets the template in the database.
    BUT although the meta in the database says
    910 827 _wp_page_template client_menus.php
    it dosent loaded into the edit window nor does it load the template???

    function my_create_page1($user_id){
    	$the_user = get_userdata($user_id);
    	$new_user_name = $the_user->user_login;
    	$my_post = array();
    	$my_post['post_title'] = $new_user_name .'_menus';
    	$my_post['post_type'] = 'page';
    	$my_post['post_parent'] = '484';
    	$my_post['post_content'] = '';
    	$my_post['post_status'] = 'private';
    	wp_insert_post( $my_post );
    
    	$justposted = $new_user_name .'_menus';
    
    	$page = get_page_by_title($justposted);
    	// $page is the post array. To just retrieve the id
    	$id = $page->ID;
    
    	update_post_meta($id, '_wp_page_template', 'client_menus.php');
    
    }

    Please help I'm scratching my hair out :(

    Reply

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.