I need to store a potentially large array of stdClass objects (houndreds of items) on my various users. Is it safe to use user meta for this, or should I rely on something else?

I could store each object as a post, I guess, but that seems overkill as I'll almost always need to use the entire list at the same time.

The list of objects are unique for each user, so they can't be shared.

1 Answer 1


If the stdClass objects are all identical in structure, I suggest to create a specific table for them and use a reference to connect to the related user.

You can use a serialized user meta to connect a user to more than one record on that table, or use a specific table's column as "user_id" if one-object <=> one-user.

  • Interesting approach. I haven't worked with custom tables in WP before, but I'll look into that.
    – Ahrengot
    Commented Feb 1, 2017 at 15:53
  • It's easy as standard mysql tables (that's actually what they are), plus the advantage of using $wpdb to place queries on it. Commented Feb 1, 2017 at 16:04
  • Actually, I just found out that the objects don't conform to the same scheme. I could manually make them conform, but it's kind of a pain in the ass. Would you still suggest a custom table?
    – Ahrengot
    Commented Feb 1, 2017 at 18:41
  • Well, I got the thing about the pain. Yep, I still suggest a custom table, use a column for each common field, use a serialized column for anything else. Commented Feb 7, 2017 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.