This article is categorised as:

WordPress: user_login vs user_nicename - The Difference

In WordPress: user_login is the username used to log in, while user_nicename is a more user-friendly version of user_login, used for author profile page permalinks

By Wasseem Khayrattee, who is a Chief Content Editor

This article has been Published on: June 5, 2023 at 03:57 AM ·  and was  Last updated: June 11, 2023 at 10:46 PM

user_login is the username used to log in. user_nicename is a more user-friendly version of user_login, used for author profile page permalinks.

Quick Difference (TL;DR)

  • user_login is the username that a user uses to log in to WordPress - the internal username. It can contain any characters, including spaces, special characters and numbers. It is meant to be used internally.
  • user_nicename is the more user-friendly version of the user_login - a user-friendly slug. It can only contain letters, numbers and underscores. It is meant to serve as the slug for the author’s profile page permalink structure.

user_nicename is basically the user_login filtered to conform to URL standards.

By default: user_nicename = sanitize_title(user_login)

Table of contents

Open Table of contents

Introduction

In WordPress, user identification is crucial for managing and organizing user accounts effectively. Two commonly used user identification attributes are user_login and user_nicename.

Although they might seem similar (at first glance), they are significant different from each other with different purpose(s) respectively.

If you are a WordPress dev, it’s even more important you get an understanding of their differences.

What is user_login?

  • user_login is used for the authentication process
  • is also technically known as the username
  • serves as the primary identifier for user accounts within the WordPress system

Format requirements for user_login

  • The ‘user_login’ string can include uppercase and lowercase letters, numbers, hyphens, underscores, periods and the at symbol (@). (Reference drawn directly from the WordPress sanitize_user function).
  • user_login must be unique

When a user creates an account on a WordPress site, they are required to choose a unique user_login - typically in the form of an alphanumeric string referred as the username or login name. User_login is used for authentication purposes and is not meant to be displayed publicly.

Editability: How to change user_login?

  • user_login cannot be changed through the WordPress admin interface once the user account is created. If you want to change this, you’ll need to use either a plugin, custom code (programmatically) or manipulate the database directly using something like phpMyAdmin or adminer.
  • If you are an advanced WordPress user or a WordPress developer, you can leverage WP-CLI as well for this purpose.
  • Generally not recommended to change, unless you really know what you are doing

WordPress: change user_login using phpMyAdmin or adminer

Visibility: Security aspect of user_login

  • user_login should not be publicly displayed to ensure security and prevent unauthorized access attempts.

What is user_nicename?

  • Technically: user_nicename is the sanitized and URL-friendly version of ‘user_login’
  • It is used for creating the user-specific URLs - the slug for the author profile page permalink URL.

For instance, if your ‘user_nicename’ is ‘wasseem’, your author archive URL will be ‘https://wk.pe/author/wasseem’.

  • By default, WordPress will auto-generate the user_nicename based on the user’s username aka the user_login

If your user_login is wasseem-khayrattee, the user_nicename will be wasseem-khayrattee

But if your ‘user_login’ is [email protected], the user_nicename will be wasseemkhayrattee-com

As you have observed, essentially: user_nicename = sanitize_title(user_login)

WordPress user_login and user_nicename via adminer interface

Format requirements for user_nicename

  • The ‘user_nicename’ string can contain only lowercase letters and hyphens. Any uppercase letters, spaces and other special characters in the ‘user_login’ are automatically converted into lowercase letters and hyphens in the ‘user_nicename’.
  • user_nicename must be unique

Editability: How to change user_nicename?

  • The ‘user_nicename’ cannot be changed directly from the WordPress admin interface by default.
  • But this can be done programmatically or using a plugin whereby you would be able to change it by simply changing the “display name” from the user admin profile interface.

In this case, WordPress will now do:

user_nicename = sanitize_title(display_name)

WordPress: How to change user_nicename

And if you view the above using a database tool like Adminer: WordPress: change user_nicename using adminer

Visibility: Security aspect of user_nicename

  • user_nicename is often displayed publicly as part of the user’s profile or in author attribution for posts and comments..etc.

Best Practices:

Choosing user_login

  • Avoid using easily guessable or common usernames to prevent brute-force attacks
  • Regularly audit user accounts to identify and address any potential security vulnerabilities
  • Use two-factor authentication to further secure your account

Choosing user_nicename

  • Avoid excessive special characters, spaces or URL-unfriendly characters in the user_nicename to maintain compatibility with permalinks
  • It’s often simpler to customize the user_nicename to reflect a user’s preferred display name

A word of caution

Whenener you do a change in either the user_login or user_nicename, do make sure to implement proper redirections or update any relevant internal links to prevent broken links and undesired effects.

Whenever you have a doubt, get the help of a professional WordPress developer.

Summary

While both ‘user_login’ and ‘user_nicename’ are crucial to user management and user identification in WordPress, they serve different purposes.

‘user_login’ is used for the authentication process and cannot be changed through the WordPress admin interface, while ‘user_nicename’ is used for author archive URLs and can be modified as needed.

Understanding the difference between these two terms can help you make better programmatic decisions when developing a feature or doing some custom coding within WordPress.


Disclosure: Our content is reader-supported. It means this post may contain affiliate links. So if you click on them and if (and only if) you make a purchase there, we'll get a commission, at no cost to you. Read more (click here) to know what this means and how you can better support us.


Share this article


Avatar of author: Wasseem Khayrattee

Written By

Wasseem Khayrattee

Wasseem Khayrattee is an experienced web professional & a senior WordPress developer with over 20 years of industry experience. He is always eager to learn, grow and connect with professionals around the globe. He has been featured in interviews & recognized in PHP[architect] magazine.