When integrating user data across plugins, it is important to have at least a basic understanding of the WordPress database schema.
WordPress stores a few key user fields in the wp_users table (where “wp_” is your database prefix):
- ID
- user_login
- user_pass
- user_nicename
- user_email
- user_url
- user_registered
- display_name
- user_status
- user_activation_key
Any other field is stored in the wp_usermeta table as a “meta” field. Meta have the following items:
- umeta_id
- user_id
- meta_key
- meta_value
To present an understanding of the relationship between these two tables and how the data structure works, consider the WP default fields “first_name” and “last_name”. These are user meta. They will be related to the user in the wp_users table by ID, where the wp_users ID field is the user_id value in the wp_usermeta table.
Let’s assume we have a user who’s username (wp_users->user_login) is “someuser”. Their ID (wp_users->ID) is 10. Their first name field would be stored in user meta with the following:
- user_id = 10
- meta_key = “first_name”
- meta_value =”Joe”
How to integrate WP-Members with user data
If you are using other plugins that collect and/or use user data, as long as those plugins follow the WordPress database schema, you can integrate WP-Members with that data scheme. You will find that most plugins that utilize user data have specific meta that they use (such as WooCommerce or bbPress), and that they are generally not flexible (at least on their “default” fields). But WP-Members accommodates this by not requiring any specific user meta. The only “required” data are what WP requires: username (i.e. “user_login”) and email.
When integrating with other plugin, you can add any specific fields you need in WP-Members through the Fields tab. You can delete any fields you don’t need (keeping in mind that most of what WP-Members installs by default for fields is simply to get you started – most of them can be deleted if they are not used).
Adding custom user meta from other plugins is not required – it’s only if you want to be able to use WP-Members features for viewing the data (such as adding custom columns to Users > All Users, or viewing the data under the WP-Members additional fields in the user profile view).