By default, when you look at the list of comments on your WP Admin dashboard, you get a list like this:
On that list, if you click on the IP address of the commenter, you go to all comments by that IP, but if you click on the email you get a mailto link, to let you email the person. That’s great, but as my friend, and fellow fansite runner, Liv pointed out, a lot of people post from multiple IP addresses these days, but only one email. What she wanted was for the icon that gave you the number of approved comments to link to that person’s approved comments.
Me, being the sort to poke around, decided to see if that could be done. I already knew how to filter columns and tables, after all. What I learned was that there actually isn’t a filter for those columns, and the only way around it was to replace it. This means I was going to have to rebuild everything, and in doing so, I wanted that email address to be a link to the search. While annoying, it was pretty easy:
<?php /* Plugin Name: Easy Comment Search By Email Description: Changes the default link for emails in the comment lists from mailto links to search results for that address. Author: Mika A Epstein (ipstenu) Author URI: https://halfelf.org Credit: https://wordpress.stackexchange.com/questions/83769/hook-to-edit-an-column-on-comments-screen */ class ecsbePlugin { public function __construct() { add_action( 'admin_head' , array( &$this, 'column_style') ); add_filter( 'manage_edit-comments_columns', function($columns) { unset($columns["author"]); $columns_one = array_slice($columns,0,1); $columns_two = array_slice($columns,1); $columns_one["author-new"] = "Author"; $columns = $columns_one + $columns_two; return $columns; }); add_filter( 'manage_comments_custom_column', function($column, $column_id) { global $comment_status; $author_url = get_comment_author_url(); if ( 'http://' == $author_url ) $author_url = ''; $author_url_display = preg_replace( '|http://(www\.)?|i', '', $author_url ); if ( strlen( $author_url_display ) > 50 ) $author_url_display = substr( $author_url_display, 0, 49 ) . '&hellip;'; echo "<strong>"; comment_author(); echo '</strong><br />'; if ( !empty( $author_url ) ) echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />"; if ( current_user_can( 'edit_posts' ) ) { $author_email = get_comment_author_email(); if ( !empty( $author_email ) ) { echo '<a href="edit-comments.php?s='; echo $author_email; echo '&amp;mode=detail'; if ( 'spam' == $comment_status ) echo '&amp;comment_status=spam'; echo '">'; echo $author_email; echo '</a><br />'; } echo '<a href="edit-comments.php?s='; comment_author_IP(); echo '&amp;mode=detail'; if ( 'spam' == $comment_status ) echo '&amp;comment_status=spam'; echo '">'; comment_author_IP(); echo '</a>'; } }, 10, 2 ); } public function column_style() { echo '<style type="text/css"> #comments-form .fixed .column-author-new { width: 20%; } </style>'; } } new ecsbePlugin();
The plugin needs a way better name, though, because this is just … bad. The array slice in the beginning was to remove the first item and replace it, without having to do a lot of overly wrought arguing with possible columns.
That said, this is the sort of thing I may submit a patch for in core, since IPs change a heckuvalot more now, and while that’s a great way to find some serial-accounts and sockpuppets, sorting by email helps you find people being trolls. Both would be good, and I don’t think a lot of us email people. If anything, I’d change the author NAME to be a mailto link.
Food for thought.