Forked from vovadocent/wp_modify_admin_user_column.php
Created
August 15, 2024 23:25
-
-
Save dgoze/fd74e5adb3af87f80eaeef78260fe818 to your computer and use it in GitHub Desktop.
Modify and add Admin User Column
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('manage_users_columns','kjl_modify_user_columns'); | |
function kjl_modify_user_columns($column_headers) { | |
//unset($column_headers['posts']); | |
$column_headers['status'] = 'Status'; | |
return $column_headers; | |
} | |
function kjl_user_posts_count_column_content($value, $column_name, $user_id) { | |
//$user = get_userdata($user_id); | |
if ('status' == $column_name){ | |
$out = ""; | |
$s = get_user_meta($user_id, 'status', 1); | |
switch($s){ | |
case 'enabled' : $colour = '#c8e998'; | |
break; | |
case 'disabled': $colour = '#ebb39e'; | |
break; | |
default: $colour = '#f0ec7d'; | |
} | |
$out = "<span style='padding:3px 8px; display:inline-block; background:$colour;'><b>$s</b></span>"; | |
return $out; | |
} | |
return $value; | |
} | |
add_action('manage_users_custom_column', 'kjl_user_posts_count_column_content', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment