Adding a Custom Column to the Users Table in WordPress

By
Advertisement
Last updated: September 2, 2014

In this tutorial I will explain how you can add a custom column to the users table in WordPress. I will go through an example of adding a custom field in the WP users table to display all post statuses and types at a glance.

I used to find myself often in the “Screen Options” area of the users table interface, unchecking some fields I didn’t want, plus trying to hunt down plugins to add fields that I did want.

These days though, I play with the functions.php file like she’s my best friend. Let me share some of my work in hopes to make your life simpler as well, even if just a little bit.

The WordPress Users Table Can Be Expanded on to Show More Post Related Data for Multi-author Sites

Let’s take the users table in the WordPress admin for example. Many people are running multi-author sites. For me… the default table data isn’t sufficient. I mean, it’s a good start, but sometimes I want to work with something that is a little more customized.

A lot of times I add unique data to the “profile edit” page and I want to expose that data in the users table. Other times, it is existing data that I want to pull in and see at a glance.

I have exposed information such as last logged in date and time, whether the user has added AdSense to their account for revenue sharing, among other things. Today though, I want to discuss something that I think just about anyone will find useful.

On one WordPress site that I administer we have the need to know what the writers are up to in a sense. We would like to see, at a glance, how many posts they have matching each status.

Let’s Go Through How to Display Post Related Data for Users for Any Post Type and Any Status

The code I offer below will work for any status, and any post type. So, even if you use custom post types and custom statuses (for example, if using the Edit Flow WordPress plugin), this will work for you.

So, rather than having a column for “Posts” with just one number in it, we can have one with several values. See the image below to get an idea of what I am referring to.



View the Original article

0 commentaires:

Enregistrer un commentaire

Fourni par Blogger.