• Hi Everyone,

    I need my site to automatically create a new page when somebody registers with the page name being the username of that user. wondering if anybody can help me out, i am relatively new to wordpress and php so any help would be awesome.

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter crewsin08

    (@crewsin08)

    Hi guys after a solid night of trial and error i managed to come up with this. seems to work pretty well, if anybody has a better idea i am happy for input.

    Simply copy paste into your functions.php file and it will take effect

    /* CREATE NEW PAGE WITH USER, GIVE PAGE USER’S NAME*/
    function my_create_page($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;
    $my_post[‘post_type’] = ‘page’;
    $my_post[‘post_content’] = ”;
    $my_post[‘post_status’] = ‘publish’;
    wp_insert_post( $my_post );
    }
    add_action(‘user_register’, ‘my_create_page’);

Viewing 1 replies (of 1 total)

The topic ‘Automatically generated pages’ is closed to new replies.