Skip to content

Instantly share code, notes, and snippets.

@jjeaton
Forked from WerdsWords/pre_comment_author_name.php
Last active December 20, 2015 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjeaton/6039101 to your computer and use it in GitHub Desktop.
Save jjeaton/6039101 to your computer and use it in GitHub Desktop.
<?php
/**
* Filter the comment author name for administrators
*
* @see wp_filter_comment(), sanitize_comment_cookies()
*
* @param string $name The comment author name.
* @return string The filtered author name.
*/
function filter_comment_author_name( $name ) {
if ( current_user_can( 'manage_options' ) )
return sprintf( __('Admin: %s', 'yourtextdomain'), $name );
else
return $name;
}
add_filter( 'pre_comment_author_name', 'filter_comment_author_name' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment