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

This site runs on Cloudways.
It's fast isn't it?
Cloudways offers high-quality, fast and affordable hosting.

Learn more

Need a hand? Post your project and hire me and other top notch developers on Codeable.

Hire me on Codeable

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
      • Sophia says

        July 22, 2022 at 9:22 pm

        Thanks so much for this.. It worked

        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
    • AGGnet says

      February 18, 2023 at 5:22 pm

      Thank you very much, you have saved my life with a multisite. It works perfectly

      Reply
      • Marinus Klasen says

        March 22, 2023 at 12:50 pm

        Glad to hear that!

        Reply
  5. Bloggista says

    July 17, 2022 at 11:12 am

    Hey thanks for this bro! I got same problem —- members not displaying in BP – Members page, and new users activation error “invalid activation key”. Got all resolved!

    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?

  • Storing private data with SSH on WPEngine sitesDecember 15, 2022
  • Get the HTML content of a block edit page or post in WordPressNovember 30, 2022
  • Rename Coupon code text to Discount code in WoocommerceNovember 3, 2022
  • Background-size cover in mPDFOctober 22, 2022
  • WordPress.com SSH & duplicating a WordPress.com website locallyOctober 11, 2022

Copyright © 2023 · Marinus Klasen | Webdesign by Team Rood