Update WordPress author

  • UserId: 1
  • Title: Update WordPress author
  • Url: update-wordpress-author
  • Summary: Update WordPress author
  • Search:
  • DateCreated:
  • DateModified:
  • Published: 1
  • Pageable: 1

Like me, many of you may have installed WordPress and begun using it as the default administrator account - admin.

The problem is, you'll later wish you'd created your own user account, which would have been tied in with each of your posts and comments. Up until 2 minutes ago, all my posts were created by admin and all comments written by me had the name admin assigned to them.

There are several options if you're in this scenario - including creating a new account and ensuring all future posts/comments use it or updating all existing records with your new account details. I opted for the 2nd option and began by working out what users were currently in the slickhouse WordPress database:

SELECT ID, user_login FROM wp_users

This will return a list of all IDs and user_logins from the wp_users table within the database. In my case, slickhouse has just the one user - admin. It's then a case of updating the user as necessary. Start by selecting all columns for the previously returned record (which had an ID of 1):

SELECT * FROM wp_users WHERE ID = 1

This returns all columns for the user admin in my case. From the results, I chose to update the following columns:

  • user_login
  • user_nicename
  • display_name
  • user_firstname
  • user_lastname
  • user_nickname
To do this, you'd run the following SQL command:

UPDATE wp_users SET user_login = 'example', display_name = 'example', user_firstname = 'example', user_lastname = 'example', user_nickname = 'example' WHERE ID = 1

Replace example with what you'd like each column to be updated to. As we've just updated the existing user, there's less work to do - the wp_posts table doesn't need to be touched, as it references the wp_users by the ID field, that hasn't changed. However, wp_comments is a different story and does need updating:

UPDATE wp_comments SET comment_author = 'Example', comment_author_email = 'example@example.com', comment_author_url = 'http://example.com' WHERE user_id = 1

This will update all comments that are associated with your admin account, to the new details. Replace example in the above with all of the information you updated the admin user to previously.

And that should be it! I carried out all of the above using the MySQL Query Browser, which can be downloaded from the MySQL site. One word of warning - ensure you've got a backup of your database prior to carrying out any of the above. Make a note of what you update, so that if you do run into difficulties you can update the records back to what they were originally - or if all else fails, restore from your backup. Again, a backup can be accomplished using the MySQL Administrator.

Categories that this Post has been filed under

  • Slickhouse - Anything to do with slickhouse.com in particular
  • Web - The Web, XHTML/CSS/ASP/.NET/SQL/PHP etc.

Tags that this Post has been tagged with


Et voila! My comments are now posted by Matt.


Add a Comment