I am trying to list the name of the moderators (users with editor role) that publish pending posts. I created a dashboard widget that shows the latest 10 published posts and the author, but I have problems getting the user that published it. I thought the_modified_author
might be it, but I'm not sure if there's a better way to tell who published the post? Either way, my method isn't working. Here's my code so far:
function dashboard_widget_function() {
$args = array( 'post_status' => 'publish', 'numberposts' => '10', 'post_type' => 'post');
$recent_posts = wp_get_recent_posts( $args );
echo '<table><tr>
<th>Post Title</th>
<th>Author</th>
<th>Moderated by</th></tr>';
foreach( $recent_posts as $recent ){
$post_author = get_user_by( 'id', $recent['post_author'] );
echo '<tr><td><a href="' . get_permalink($recent["ID"]) . '" title="Read: '.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a></td>';
echo '<td>'. $post_author->display_name .'</td>';
echo '<td>'.get_the_modified_author().'</td></tr>';
}
echo '</table>';
}