how can I fetch a list of registered users and show it in the admin panel. I know theres the list inside the admin panel already but I’ve added a few tables and I need to show them in a new tab menu inside the admin panel.
Leave a Reply
You must be logged in to post a comment.
What you’ve done is incredibly bad practice, and should be undone immediatley. There is already a dedicated table for storing user details aka User Meta. Altering the user table could cause issues with other plugins and Core, prevent upgrades working, and bypasses all the caching and object stores WordPress puts in place. It also adds additional avenues for SQL injections.
TLDR: Never modify Core WP Tables
Instead use the provided User Meta API:
They work in the same way get_post_meta etc work, and there is already a dedicated table, and additional APIs for querying via
WP_User_Query
.Then display this using the answer here:
How to display multiple custom columns in the wp-admin users.php?
To search for users based on meta use the
WP_User_Query
class. Using this you can grab lists of users with specified meta data, e.g.