Okay, after several hours of searching and playing around, I came up with the following plugin that does 4 things on the Edit Posts admin page:
1- Removes the Author column.
2- Adds a new column called realAuthor which displays the whats stored in the custom meta data field called ddfmName.
3- Adds a new column called realAuthorEmail which displays the whats stored in the custom meta data field called ddfmEmail.
4- Adds a new column called ID and displays the Post ID number (older versions of WP did this by default).
<?php
/*
Plugin Name: Display ID & Custom fields
Version: 0.1
Plugin URI:
Description: On the Edit Posts list view page, it will display the Real Authors name and email, and the Post ID. All submissions to the blog are made by the 'anonymous' author (#5), but the persons real name and email are stored in the meta-data custom fields called 'ddfmName' and 'ddfmEmail'... This Real Name and Email will be displayed.
Author: Jeff Sherk
Author URI:
*/
///////////////////////////////////////////////////////////////
//Add realAuthor column
function jds_realAuthor_column($column) {
$column['realAuthor_column'] = '<abbr style="cursor:help;" title="ID">realAuthor</abbr>';
unset($column['author']); //remove the original author column since we don't need it
return $column;
}
function jds_realAuthor_column_content($column,$ID) {
global $post;
if( $column == 'realAuthor_column' ) {
if ($post->post_author == '5') { // 5 is author = 'anonymous'
$realAuthor = get_post_meta($ID, 'ddfmName', true); //use TRUE to return single value as string
echo $realAuthor;
} else {
$originalAuthor = get_the_author($post->post_author); //If it's not anonymous then get original author/admins name
echo '<a href="https://www.forerunnertv.com/more/wp-admin/edit.php?author='.$post->post_author.'"><strong>'.$originalAuthor.'</strong></a>'; //This is how the the original Author column displays it, so we do it that way too!
}
}
}
//Add realAuthor to posts only since it does not apply to pages
add_filter('manage_posts_columns', 'jds_realAuthor_column', 5, 2);
add_action('manage_posts_custom_column', 'jds_realAuthor_column_content', 5, 2);
///////////////////////////////////////////////////////////////
//Add realAuthorEmail column
function jds_realAuthorEmail_column($column) {
$column['realAuthorEmail_column'] = '<abbr style="cursor:help;" title="ID">realAuthorEmail</abbr>';
return $column;
}
function jds_realAuthorEmail_column_content($column,$ID) {
global $post;
if( $column == 'realAuthorEmail_column' ) {
if ($post->post_author == '5') { // 5 is author = 'anonymous'
$realAuthorEmail = get_post_meta($ID, 'ddfmEmail', true); //use TRUE to return single value as string
echo '<a href="mailto:'.$realAuthorEmail.'?subject=Your submission to ForerunnerTV.com">'.$realAuthorEmail.'</a>';
}
}
}
//Add realAuthorEmail to posts only since it does not apply to pages
add_filter('manage_posts_columns', 'jds_realAuthorEmail_column', 5, 2);
add_action('manage_posts_custom_column', 'jds_realAuthorEmail_column_content', 5, 2);
///////////////////////////////////////////////////////////////
//Add ID column
function jds_id_column($column) {
$column['id_column'] = '<abbr style="cursor:help;" title="ID">ID</abbr>';
return $column;
}
function jds_id_column_content($column,$ID) {
if( $column == 'id_column' ) {
echo $ID;
}
}
//Add ID to both posts and pages
add_filter('manage_posts_columns', 'jds_id_column', 5, 2);
add_action('manage_posts_custom_column', 'jds_id_column_content', 5, 2);
add_filter('manage_pages_columns', 'jds_id_column', 10, 2);
add_action('manage_pages_custom_column', 'jds_id_column_content', 10, 2);
?>