Title: Errors in your plugin&#039;s wp_rewrite code
Last modified: September 1, 2016

---

# Errors in your plugin's wp_rewrite code

 *  [trickypaladin](https://wordpress.org/support/users/trickypaladin/)
 * (@trickypaladin)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/errors-in-your-plugins-wp_rewrite-code/)
 * After checking “Set user’s Author Base according to their role. (The above “Author
   Base” setting will be used as a fallback.),”
 * a user having a role of, e.g., “contributor” can be found at /contributor/firstname-
   lastname, but also at /administrator/firstname-lastname, /author/firstname-lastname,
   etc. All the user role base urls will load up any user’s page after checking 
   the box.
 * Can this be fixed so that the user roles not assigned to the user are not mapped
   to the urls for the unassigned user roles?
 * Thanks
 * [https://wordpress.org/plugins/edit-author-slug/](https://wordpress.org/plugins/edit-author-slug/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [trickypaladin](https://wordpress.org/support/users/trickypaladin/)
 * (@trickypaladin)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/errors-in-your-plugins-wp_rewrite-code/#post-7605835)
 * To fix this, you will also have to prevent duplicate “Role Slugs” set by the 
   user. Currently, the same value can be set for all $author_base portions of each
   slug.
 *  Plugin Author [Brandon Allen](https://wordpress.org/support/users/thebrandonallen/)
 * (@thebrandonallen)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/errors-in-your-plugins-wp_rewrite-code/#post-7605945)
 * Correct, each user will be available under every role slug. This isn’t so much
   an error, as it is a trade-off. In theory, none of the other URLs are exposed
   to the outside world when using standard WP functions, i.e. – `get_author_posts_url()`
   or `get_the_author_posts_link()`. The alternative is to generate rewrite rules
   for every user, every time a user is updated or created. This is expensive, and
   with large user numbers, would cause the rewrite rules to be large and reduce
   performance.
 * It may be possible to use the `template_redirect` hook, or the `redirect_canonical`
   filter, to enforce a canonical role-based URL, but I haven’t looked into this.
   If you’d like to explore the idea, and, assuming it works, submit a pull request
   on GitHub, I’d be more than happy to review it 🙂 Past that, I don’t have a timeline
   as to when I might explore the idea.
 * As far as duplicate role slugs. I don’t see a reason that you couldn’t have duplicates.
   I can think of reasons you shouldn’t, but none where you couldn’t.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Errors in your plugin's wp_rewrite code’ is closed to new replies.

 * ![](https://ps.w.org/edit-author-slug/assets/icon.svg?rev=1582213)
 * [Edit Author Slug](https://wordpress.org/plugins/edit-author-slug/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/edit-author-slug/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/edit-author-slug/)
 * [Active Topics](https://wordpress.org/support/plugin/edit-author-slug/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/edit-author-slug/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/edit-author-slug/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Brandon Allen](https://wordpress.org/support/users/thebrandonallen/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/errors-in-your-plugins-wp_rewrite-code/#post-7605945)
 * Status: not resolved