Skip to content

Instantly share code, notes, and snippets.

@dasbairagya
Created May 4, 2017 08:37
Show Gist options
  • Save dasbairagya/e981a5732243718ac087874ec9211dfc to your computer and use it in GitHub Desktop.
Save dasbairagya/e981a5732243718ac087874ec9211dfc to your computer and use it in GitHub Desktop.
Add custom columns to the user table of the admin dashbord
<?php /**
* Adds a custom column to the user display dashboard.
*
* @param $columns The array of columns that are displayed on the user dashboard
* @return The updated array of columns now including zip codes.
*/
function new_modify_user_table( $column ) {
$column['register_phone'] = 'Phone';
$column['zip_code'] = 'Zip';
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 'register_phone' :
return get_the_author_meta( 'register_phone', $user_id );
break;
case 'zip_code' :
return get_the_author_meta( 'zip_code', $user_id );;
break;
default:
}
return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment