Note to curators/admin: I wanted to leave a comment but I didn’t have enough reputation. I know I am not formally providing an answer, but attempting to help the person asking the question along.
Are you using any membership plugins? Can you give us a little more information on the overall site map and functionality? We are seeing a very narrow field of a bigger question to assess.
You’re on the right path with the custom post type, but I think there is a better way to go about the situation.
I will assume from your provided code example that you have a decent understanding of PHP/Wordpress codex to best help explain what I mean to say would be the best idea here.
A more practical approach to generating public facing user profile pages would be a controlling theme function such as /profile/<foo>
that looks up relevant user information. From there, you would pass permissions to each profile page to the user, who would need to login and edit their information either through the WordPress dashboard. Or, users fill out profile information from another front-end page that feeds the public page.
If you are getting confused writing custom post types, you may want to install a turn-key solution. Without mentioning any brand names, there are many existing (and free) membership plugins that give the user a public profile + account management area.