Makers Byte
Published in

Makers Byte

How to add Custom Meta Field to User Listing at the Admin Panel WordPress?

Add custom column to Users admin panel

One of the reasons WordPress is so popular among users is that it provides us with a great user management system and ability to create multi-author blogs and publication platforms. However in some cases there is a necessity to expand the default user information, and add more fields to the user profile.

via unsplash.com

In this tutorial WordPress add meta box to user profile.

Few days back, we had a requirement from a customer where they wanted to have a field for “Points” in the user listing area at WordPress Admin Panel. We hacked together something which does this job for us.

Steps to follow:

  1. Open functions.php file of your WordPress theme
  2. Paste the full code (shared below) in functions.php file. This will add new field on user profile for “User Points” and add a column user table on WordPress admin for User Points.

Here is the code to allow your users to add points field:

function new_modify_user_table( $column ) {
$column['userpoints'] = 'User Points';
return $column;
}
add_filter( 'manage_users_columns', 'new_modify_user_table' );
function new_modify_user_table_row( $val, $column_name, $user_id ) {
switch ($column_name) {
case 'userpoints' :
return get_the_author_meta( 'totalpoints', $user_id );
break;
default:
}
return $val;
}
add_filter('manage_users_custom_column','new_modify_user_table_row', 10, 3 );

Note — In the above code our source for userpoint is the author information which in any case can be replaced with what ever information you plan to pass.

And If you enjoyed this post…it would mean a lot to me if you could click on the “claps” icon…up to 50 claps allowed — Thank You!

--

--

--

Resource hub for Designers/Developers

Recommended from Medium

100 Leetcode challenge: №7

How to upload a plugin to WordPress Plugin directory

Complicated isn’t always better

Beginner’s Mind vs. Imposter Syndrome

When Do You Become A Developer?

Working with Amazon SNS with Boto3

Open Source Contribution made easy

Again, it’s theory versus practice

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shahzaib Khan

Shahzaib Khan

Data Scientist, Developer, Tech Writer, Entrepreneur and Computer Science Enthusiast. Connect at https://www.linkedin.com/in/shahzaibkhan/

More from Medium

How to make Woocommerce Shopping Cart responsive?

Web3 WordPress Plugin: DePay Donations is here!

5 SEO Tips For WordPress You Should Know

My first website design