User display name as slug (instead of login name)

What is wrong with having a listing of user’s post in {site name}/author/{user login}? Two things

  1. It allows an attacker to easily figure out the user name he should attack
  2. It can get ugly if due to a lapse of thinking you registered your account as qwerty, but after it was done it is very hard to change it to anything else

This plugin solves both problems by making the slug (the last part of the URL) for the author’s posts page to be based on his display name, or a random string if he didn’t set one yet. Although it is not enforced in the code, it is unlikely to have to authors with the same display name as it will just be too confusing to everyone in other aspects of the site as well.

How does it work?

For new users, the slug is set to user-nnnnnn.

Once the user had updated his display name, lets say to “barak obama”, the slug is changed to “barak-obama”. Updating againĀ  to “president obama” will update the slug as well to “president-obama”.

If for some strange reasons there are two users with the same display name a suffix will be added to the slug in the form of “-nn”, in a similar way to what happens to posts with the same slug.

If you have decided to changes the slug manually by using some other plugin or tool, the slug will stop to update automatically when the display name is changed.

Users that were create while the plugin was inactive will get their new slug once the user visits the admin.

SEO considerations

The plugin do not redirect from the login name style url to the display name style, and will not redirect between old and new display name if it is being changed. We assume that in almost all the sites the author’s post page is not worth the effort to keep track of the changes.

Settings

None. It just works.

Compatibility

WordPress versions 4.3 and above. Will work with standalone or multisite/network WordPress configuration.

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment policy

We are not going to share your e-mail with anyone else, but we might send you answers to your questions directly to your email.