10

Can someone explain the differences or different uses of the user_name and user_nicename fields in the users table? They seem to be, and behave the same.

I found a bunch of posts in web searches, but they are relevant only to older version of wp.

10

The nicename is (usually) just a sanitized version of the username. It's suppose to be 'nice' in the sense that it is the 'nicename' that is used as a slug, for example:

www.yoursite.com/author/my-nice-name/

will take you to the archive of the author with nicename 'my-nice-name'.

The documentation simply describes it as

A string that contains a nicer looking name for the user.

  • Thanks - what type of characters are allowed during sign-up that would be removed during "sanitization"? – GWR Feb 18 '12 at 13:28
  • sanitize_title does the sanitizing. According to this it strips HTML & PHP tags. It seems to replace spaces with '-' somewhere. Note if you provide a nicename in wp_insert_user it doesn't do any sanitizing. – Stephen Harris Feb 18 '12 at 13:47
  • Got it... makes perfect sense. – GWR Feb 18 '12 at 15:51
  • The fact that the documentation says "A string that contains a nicer looking name for the user." is really confusing. You would think that this meant that a "nice" name is one with capitals and spaces, pretty for the user, but apparently, it is exactly the opposite! – Flimm Aug 30 '19 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.