I believe the solution here would be as simple as you’ve generally described it.
Assuming conveniently that $wp_query->query_vars['user'] contains the username and not its ID:
if ( array_key_exists( 'user', $wp_query->query_vars ) ) {
if ( username_exists( $wp_query->query_vars['user'] ) ) {
include( TEMPLATEPATH . '/user-profile.php' );
} else {
include( TEMPLATEPATH . '/404.php' );
}
exit;
}
Related Posts:
- Custom user profile URLs
- How to create a front end user profile with a friendly permalink
- WordPress Rewrite
- Why is there /index.php/ in all my links? How do I remove it?
- WordPress plugin Write User/staff ID as the same as the WordPress User ID
- How to add a user profile page to frontend?
- Attachment page gives 404 if user not logged
- Using a custom 410 page
- Add Link to Users List (Backend) to open each users front-end profile
- Why when I enter bad url wordpress doesn’t return error 404
- 404 redirect based on url
- Showing user profile data on front-end
- Thousands of 404 errors on old posts due to embedded links
- Get logged in username in wordpress url
- Adding Theme File for Non-WordPress Content
- Page not found: Custom search form with a custom search page
- Show index.php template instead of 404 page template
- Redirect empty search to another page
- Custom taxonomy named ‘tag’ return 404 page
- Change author base and slug in author link
- Why is there a 404 on page 2+ for my search page?
- Param causing 404
- Add an ‘edit profile’ page with Genesis
- Error 404 wordpress redirecting URL
- Add dynamic url with external page in WordPress
- add_rewrite_rule is not fired
- Custom Rewrite for Profiles
- Stop wordpress to redirecting home page if no page found
- How can i maintain permalink structure and avoid a 404 error when loading external content?
- 404 for index.php
- User profile in front-end
- How to disable WordPress canonical redirect to nearest matching URL and force 404 Page?
- Change the Author Slug from Username to Nickname
- Rewrite rules not working in WordPress
- rewrite rules and querystring
- User Profile / Add Custom Fields
- How to Save Different Usermeta Fields According to User Role?
- how to add prefix to post url structor only
- How do I remove a word from a url in WordPress using .htaccess?
- Child pages on hierarchical Custom Post Types 404s
- Rewrite Rule for Custom Page with Query Vars in URL
- wp_sanitize_redirect strips out @ signs (even from parameters) — why?
- WP Rewrite the last two parts of the URL
- Rewrite URL to remap WordPress Permalink
- WordPress redirection to get url friendly
- Access $_POST data after redirect
- How to add a custom redirect rule for subdomains?
- How to remove WordPress category from URL and have a custom pagination parameter/rewrite?
- user-new.php less detailed after WP3.1; how to revert?
- Is it possible to rewrite URLs in this situation?
- Adding pretty query parameters
- Problem with add_rewrite_rule
- add_rewrite_rule ignoring other params than the “p” param
- Adding two rewrite rules
- Load an url with minimal/no DB queries
- .htaccess rewrite
- Front-end editing with custom fields?
- Auto generate rewrite rules for multiple taxonomies
- Change htaccess to redirect to index.php in subfolder
- rewrite url for authors
- How to redirect specific URL to Subdomain
- Force search form to go to clean url without multiple redirects
- Rewrite query string to path
- map multiple URLs to display home page without changing URL displayed in browser’s location bar
- WordPress Autocorrect URL / Slugs Does Not Work
- Profile page for user roles
- Rewrite URL for single category
- Help with rewrite rules for two post types
- Permalinks 404 error with HTTPS host
- Flush rewrite rules on option update with Settings API
- Integer based rewrite isn’t recognized for value of 1
- Re-directing URLs with dates to URLs without dates
- Help with a custom rewrite
- Permalink Problems
- Not able to rewrite the pagination URL for the posts
- 404 permalink errors on Pages only
- 301 Rewriting htaccess
- Give users alternative/second avatar that is rectangle sized
- Using page as front page, why does /page/### work?
- A change in URL slug in database returns 404, how can I do auto-redirect?
- How to limit post (Exception pages) for current user in each role in front end?
- How to add dot(“.”) in post slug
- WordPress pagination broken for page 2,3 with custom permalink. Redirects to baseurl
- Rewrite rule for custom permalink structure
- Unable to access the query variables in the template
- Custom rewrite from URL to URL using slug
- URL rewrite before template_redirect called
- Properly maintaining an old rewrite structure
- Folder Name and Category Name WordPress
- .htaccess RewriteBase equivalent for WordPress – Passing a URL as a variable without getting a 404
- URL Rewrite for CPT single posts
- Rewriting WordPress URLs
- Need Help With A Rewrite Issue
- Function to rewrite URl in WordPress
- Can’t get pretty permalinks to work without index.php
- get parameter from url rewrite [closed]
- add_rewrite_rule not working with custom variables
- Can we get user profile page using user_id in the URL?
- Issues with creating user profile for a subscriber, but with different profile page and functionalities
- How to keep rewrite_rule without flushing each time?