I tested your code, fixing the $colum_name
issue and it works ok for me.
add_filter('wpmu_blogs_columns', function ($site_columns) {
$site_columns['expired_Date'] = 'Expires';
return $site_columns;
});
add_action('manage_sites_custom_column', function ($column_name, $blog_id) {
if ( 'expired_Date' === $column_name ){
$current_blog_details = get_blog_details(array('blog_id' => $blog_id));
// do_action( 'qm/debug', ['Details:', $current_blog_details ] );
echo ucwords($current_blog_details->last_updated);
}
}, 10, 2);
You have to check the $column_name
otherwise the echo
will print in all custom columns.
Both the filter and the action are pretty specific, they will only run on the page /wp-admin/network/sites.php
and nowhere else.
I tried the code above using Snippets plugin and also as a mu-plugin and both worked the same, haven’t tried as a plugin (maybe you can wrap everything inside a add_action('plugins_loaded', function(){});
hook).
The qm/debug
is for the plugin Query Monitor, a must-have for WP devs 🙂