I've got my user registration to automatically create a post with the user_register hook however the title shows up as (no title) can someone help me with what I'm doing wrong here?
add_action('user_register','create_new_user_post');
$userinfo = get_userdata($user_id);
$disname = $userinfo->display_name;
function create_new_user_post($user_id){
if (!$user_id>0)return;
// Create post object
$my_bio_post = array(
// 'post_type' => 'ggs_user_post_type',
'post_title' => $disname,
'post_content' => 'Put cool content here!',
'post_status' => 'publish',
'post_author' => $user_id
);
// Insert the post into the database
$bio = wp_insert_post( $my_bio_post );
//and if you want to store the post ids in
//the user meta then simply use update_user_meta
update_user_meta($user_id,'_bio_post',$bio);
}