Customizing WP tables or adding new ones?

You should avoid adding new tables or customising the existing tables to add fields for users.

If you want to store a phone number etc, do it using user meta:

add_user_meta( $user_id, 'riccardo_phone_number', '0123-456-7890' );
....
$phone_number = get_user_meta( $user_id );

User meta is a key and a value with a post ID in the database. There is no need for changes to the table structure/schema to add new information.

Modifying the WP_User table will cause major issues with future upgrades of WordPress. When WordPress Core modifies their Database schema, you run the risk of it failing on update, or data destruction.

Creating new tables and modifying the core tables also means writing custom SQL queries, duplicating the main query, and giving up all the APIs for data access, as well as introducing a new point of failure. Custom post types, post meta, and custom taxonomies are almost always a better choice, bringing other benefits with them.

Leave a Comment

error code: 523