Change the author slug from nickname to ID

Surprised to see this unanswered for this long. This is pretty simple to do with a simple block of code:

function set_my_nice_name() {
    global $wpdb;
    $user_table = $wpdb->prefix . 'users';
    $wpdb->query("UPDATE $user_table SET `user_nicename`=`ID`");
}
add_action('init', 'set_my_nice_name');

This works because the visible portion of an author slug (or profile slug in BuddyPress) uses the user_nicename column in the users table and this just copies the user ID to that column for everyone in the DB.

Leave a Comment