Was working on this, thought to blog.

Sometimes it's needed to add extra column on user table to show extra property file a custom meta field or something like this. Let's say you want to list a column called "Customer Since" on user table which will display the registration date of your user.

Okay we'll do it now.

To achieve this we will have to use to action hook called "manage_users_columns" and "manage_users_custom_column"

First will have to add the extra column on the table.

function register_custom_user_column($columns) {
    $columns['customer_since'] = 'Customer Since';
    return $columns;
}

Now generate the value

function register_custom_user_column_view($value, $column_name, $user_id) {
    $user_info = get_userdata( $user_id );
    if($column_name == 'customer_since') return $user_info->user_registered;
    return $value;

}

Finally hook them

add_action('manage_users_columns', 'register_custom_user_column');
add_action('manage_users_custom_column', 'register_custom_user_column_view', 10, 3);

Aaand, that's it.




What's on your mind?


7 Comments

11b95ec11ecff6ad0cdd76d367777128?s=100
Finn commented 3 days ago

excellent issues altogether, you simply gained a new reader. What could you suggest in regards to your put up that you just made some days ago? Any positive?

C3f72f454cac150ca5e907a4d8e0de4e?s=100
minkys lash extensions training commented 3 days ago

Great items from you, man. I have take note your stuff previous to and you're simply extremely fantastic. I really like what you've acquired here, certainly like what you are saying and the best way in which you assert it. You are making it entertaining and you continue to care for to stay it wise. I cant wait to learn much more from you.

That is really a terrific site.

94164add3bcf1c73bbe58689c056fdbf?s=100
madden mobile coin seller commented about 19 hours ago

At this time it appears like Drupal is the top blogging platform available right now. (from what I've read) Is that what you are using on your blog?

E878022064f1385bd439588b645b931a?s=100
http://arcmos.com commented 3 days ago

If some one needs expert view about blogging and site-building after that i suggest him/her to pay a visit this webpage, Keep up the nice job.

7f79ee565394ba4795754ae43736f2b4?s=100
csgo skins for sale paypal commented about 17 hours ago

I don't even know how I stopped up here, however I assumed this submit was great. I don't recognise who you're however certainly you're going to a well-known blogger should you aren't already.

Cheers!

5411ddc4cdfbd208d0582330834ff544?s=100
madden 17 coins free commented 3 days ago

Appreciate the recommendation. Will try it out.

F236c59ccb9e9a50c23a3430c79b33d6?s=100
modmanpaul commented almost 2 years ago

perfect thank you. I used this to display a custom user meta value I create on registration. can you tell me how to make this new column searchable? i don't need to sort by it but when I search for the value (a number) it says no users found