Marinus Klasen

Marinus Klasen

  • Development
  • Consultancy
  • Developer Resources
  • Blog
  • Contact

January 14, 2021

Fix for missing spam column in wp_users

Marinus Klasen

While converting a website from single to multisite I bumped into an issue while creating accounts. When looking into the logs I noticed:

WordPress database error Unknown column ‘spam’ in ‘field list’ for query INSERT INTO wp_users

The issue is clear, i’m missing the ‘spam’ column in wp_users. Since i’m running this environment in Docker and I didn’t have easy database access available I wrote a wp-cli command fixing this issue;

Thanks to RJT for improving the script!

About Marinus Klasen

Marinus has been working in software/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge.

Marinus Klasen on Twitter

Comments

  1. Uchechukwu Ajuzieogu says

    June 7, 2021 at 8:37 am

    Hi Marinus,

    I am facing the same issue in WordPress Bitnami Stack, how do I do this, is there is step by step guide, I’m not familiar with CLI of WP.

    Thank you

    Reply
    • Marinus Klasen says

      June 7, 2021 at 9:29 am

      Hi there – you can access your database and run the following command: ALTER TABLE wp_users ADD spam TINYINT

      Reply
      • Shammy says

        May 23, 2022 at 10:49 am

        Thank You! It work for me.

        Reply
  2. Ronnie Roberts says

    September 10, 2021 at 6:59 pm

    When I run that command, with root user, I receive the error:
    “Invalid default value for ‘user_registered'”

    Any thoughts?

    Reply
    • Marinus Klasen says

      September 10, 2021 at 7:09 pm

      Seems like something is wrong with the user_registered column in your table. I would have to have a look myself in order to give further advice. Feel free to reach out by email!

      Reply
  3. jld says

    October 13, 2021 at 3:07 pm

    Thanks to your article, I solved my issue, thank you very much !

    Reply
    • Marinus Klasen says

      October 19, 2021 at 9:32 am

      Happy to hear that!

      Reply
  4. RJT says

    June 22, 2022 at 4:06 pm

    Important addition: the database column should default to 0 not null, so the query should be:

    ALTER TABLE wp_users ADD spam TINYINT NOT NULL DEFAULT 0;

    If the spam column is missing, it’s likely the the ‘deleted’ column is also missing (both should be added when converting to multisite). This should column also needs to be added.

    ALTER TABLE wp_users ADD deleted TINYINT NOT NULL DEFAULT 0;

    Reply
    • Marinus Klasen says

      June 22, 2022 at 4:50 pm

      Thanks! I’ve updated the script according to your recommendations.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Ready to take action?

I'm looking forward to discuss your projects and goals!
Feel free to reach out using the contact details below.

Marinus Klasen

[email protected]
twitter.com/marinusklasen
linkedin.com/in/marinusklasen

  • GitHub
  • LinkedIn
  • Twitter

Have you read?

  • An easy way to copy code blocks from the WordPress Block EditorJune 9, 2022
  • Set a static IP for docker-compose containersMay 25, 2022
  • Justified auto width in Media Carousel Widget in ElementorMay 18, 2022
  • Using the WordPress REST APIMay 18, 2022
  • Remove all edit post links in WordPress with a simple filterMay 11, 2022

Copyright © 2022 · Marinus Klasen | Webdesign by Team Rood