I'm trying to create a post when a user registers using the code from here:
Create posts on user registration
The user registers and the post is created BUT the user firstname and user lastname is not working. Each time a post is created just with the title of "Bio"
Here is my code:
function create_new_user_posts($user_id){
// Get user ID for Post Title
$user = get_user_by('id', $user_id);
if (!$user_id>0)
return;
// Here we know the user has been created so to create a post we call wp_insert_post
// Create post object
$my_bio_post = array(
'post_title' => $user->user_firstname . " ". $user->user_lastname . 'bio',
'post_content' => '[li_profile id="author"]',
'post_status' => 'publish',
'post_author' => $user_id
);
// Insert the post into the database
wp_insert_post( $my_bio_post );
}
add_action('user_register','create_new_user_posts');