I’d like to develop a plugin that allows me to have custom user pages. I really like the way the author archive template handles the URL: /author/username. I don’t want to rewrite the author_base
as I’d like to keep that functionality in place untouched.
I’d like to replicate that clean URL layout in my plugin, so that when a user goes to /users/username it will go to my custom template. I’d like to know if anyone has examples of how to properly parse the username from the URL so that I can lookup the user’s data from the plugin and display my template.
I found the answer to this from @bybloggers answer found here. https://wordpress.stackexchange.com/a/58793/12920
I modified his code very slightly to tailor it to my needs, but this is the code that worked for me and was exactly what I was looking for:
After this was in my
functions.php
file, I had to re-save my Permalinks.Sometimes re-saving the permalinks didn’t finish the job 100% and browsing to http://www.mysite.com/member/username would 404, so I had to manually flush the rules by putting this into my
functions.php
and loading my site once. Then removing it so I don’t run it every time the site loads, since that’s unnecessary overhead.