Create new post on user registration

Check out the documentation for the get_user_by() function'user_firstname' and 'user_lastname' aren’t properties of the returned object. This is because this data is not a part of the user model – rather they are stored in user metadata.

You should be able to use the get_userdata() function, as it returns an object containing both user properties as well as user metadata.

Alternately, you can use get_user_meta() to retrieve the specific metadata you’re looking for:

$first_name = get_user_meta( $user_id, 'first_name', true );