• Hi everyone,
    I’m a MT convert, and I must say that WordPress is a wonderful environment to work in. I’m impressed over and over again. My one problem stems from the fact that I didn’t quite understand what was happening during the import process. After importing, I found that I have three users defined in WP, although I would prefer to have only one. To make matters worse, all of the imported posts belong to a user I don’t use. Is there a way to set the owner of all the posts to the user I want to use, and then to remove the inactive users?
    Thanks!
    Jason

Viewing 7 replies - 1 through 7 (of 7 total)
  • BACKUP YOUR DATABASE BEFORE FOLLOWING THESE INSTRUCTIONS
    It’s a single SQL command to change the post authors for all your posts. Using phpMyAdmin (or the MySQL interface of your choice), try this:
    update wp_posts set post_author=1;
    That’ll set the default WP admin user as the author of all your posts. Confirm this worked correctly, then feel free to delete your other users.

    Thread Starter varrus

    (@varrus)

    Ahh – thanks. I was hoping it could be done through the WP admin interface – unfortunately, my web host does not provide phpMyAdmin. Are there any MySQL interfaces that I can just install myself?

    If you have shell access to your host, you can use the mysql command-line tool:
    $ mysql -u<username> -p
    Password: <enter password>
    mysql> use <WP database>;
    mysql> update wp_posts set post_author=1;
    mysql> quit;

    Or you could whip up a quickie PHP file to do it for you, and upload it to your wp-admin directory:
    <?php
    require('../wp-blog-header.php');
    $sql = "update wp_posts set post_author=1;";
    $result = $wpdb->get_result($sql);
    echo $result;
    ?>

    Thread Starter varrus

    (@varrus)

    Wow, thanks skippy! Now, before I run this, would I be able to do a select to make sure that I’m setting the posts to the correct user? Something like:
    <?php
    require('../wp-blog-header.php');
    $sql = "select distinct post_author from wp_posts;";
    $result = $wpdb->get_result($sql);
    echo $result;
    ?>

    You could include as much conditional logic as you want. The select statement you provide would only report the unique userIDs assigned to each current post. As I read your original message, it sounded like you already knew who the author was, and it was incorrect — thus this discussion.
    UserID #1 is always your default WordPress administrator. If you don’t want all posts to belong to the admin, just substitute whatever userID you need into the query I provided.

    Thread Starter varrus

    (@varrus)

    I’m pretty sure it’s #1 that I want to set them to – I’m just being paranoid. I work in QA – LOL.
    Thanks for the help!

    How to you delete a user?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Consolidate Users’ is closed to new replies.