What’s the most efficient way – concerning the database – to add and query extra usermeta fields to a profile?

I need to add four additional fields of numeric and text data to a user profile and then query that to compile the data for display in a template. And there are potentially thousands of users.

There are lots of examples to store the data in usermeta. But should this amount of data be stored in the usermeta table?

Or should I store it all in a new database table? And if so, how do I initialize a new table and then write to it?

2 Answers
2

There are lots of examples to store the data in usermeta. But should
this amount of data be stored in the usermeta table?

I don’t see any reason why you should not use the default user meta data table, after-all that is what it is for, regardless of the amount of users/fields.

The user meta function , such as get user meta uses get_metadata with the $meta_type object set to user. http://codex.wordpress.org/Function_Reference/get_metadata

If you want to mess around with new tables you can use the $wpdb class and create a new one, this post covers how, http://codex.wordpress.org/Creating_Tables_with_Plugins .

There is also a plugin called Pods CMS that allows for the creation of custom database tables for content types, but unless you have a specific reason for doing so, just use the built in user meta tables.

Leave a Reply

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