'How to add extra content to the WordPress admin user table Name column every cells
I want to add extra information after every name, in the name columns cells, How may I do that? default columns like names, email, role are not pass on manage_users_custom_column hook. I tried the below code but not working!
add_filter( 'manage_users_custom_column', 'add_extra_text_after_every_name', 10, 3 );
function add_extra_text_after_every_name( $output, $column_name, $user_id ) {
if ( 'name' == $column_name ) {
// is not working, because default fields name didn't pass
}
return $output;
}
thanks in advance for your reply.
Solution 1:[1]
You can't because that field is from wordpress default swtich cases, so this never will take that filter, you can see this in the wordpress/wp-admin/includes/class-wp-users-lists-table.php line #547
case 'name':
if ( $user_object->first_name && $user_object->last_name ) {
$r .= "$user_object->first_name $user_object->last_name";
} elseif ( $user_object->first_name ) {
$r .= $user_object->first_name;
} elseif ( $user_object->last_name ) {
$r .= $user_object->last_name;
} else {
$r .= sprintf(
'<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
_x( 'Unknown', 'name' )
);
}
break;
The only thing that you can do, is add new columns and data
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Cristino |