frankl23
Member
Posted 2 years ago #
I'd like to create a new page for each user that registers on my site when they register. I can't find a plug-in that deals with this. Has anyone tried to do this before? Content of the new page would be a custom function (from my theme's functions.php) with the user ID as a parameter.
Thanks for any suggestions
davidneudorfer
Member
Posted 2 years ago #
I'm looking for the exact same thing. Any luck? Thanks.
ben_allison
Member
Posted 1 year ago #
ben_allison
Member
Posted 1 year ago #
I figured it out. This goes in functions.php (or a plugin if you like). It will create a post (or any custom post-type you've defined) and makes the posts's title the same as the user's name.
/* CREATE NEW POST WITH USER, GIVE POST 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'] = 'post';
$my_post['post_content'] = '';
$my_post['post_status'] = 'publish';
wp_insert_post( $my_post );
}
add_action('user_register', 'my_create_page');