This code does the job with a filter. Doesn’t care what the comment says the author’s name is.
Nothing particularly tricky about it. Should be self-explanatory.
add_filter('get_comment_author', 'wpse31694_comment_author_display_name');
function wpse31694_comment_author_display_name($author) {
global $comment;
if (!empty($comment->user_id)){
$user=get_userdata($comment->user_id);
$author=$user->display_name;
}
return $author;
}
Related Posts:
- Writing a plugin that notify my friends of new post that mentions(@) them
- Why are two functions over-riding each other?
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- comment_email hook doesn’t seem to work for comment editor field
- Show comments fields in two columns
- preprocess_comment array doesn’t have comment_ID
- How do I alter the comment form ‘allowed tags’ text in a plugin?
- Can wp_list_comments output into variable?
- WordPress comments on users profile
- $reverse_top_level works the opposite way according to Codex?
- Display custom fields in frontside user profile
- How to integrate CLEditor to comment system?
- Get attachments from a post
- is pre_get_comments not working?
- How to pull user/author profile data in a plugin?
- How to replace default comments with custom HTML?
- First and last name fields not filled when using wp_insert_user
- How do I change the image from the default mysteryman in the WP Profile page
- Custom avatars in wordpress comments?
- why do I have to use required parametres?
- get author of published post
- How to get custom post_author?
- how to load the comment template from a plugin
- Update a user profile via frontend
- Change author permalink to external URL
- How to get the number of pages when paginating comments?
- How does “Your comment is awaiting moderation” work?
- how to get the top 10 popular blogs
- disable defaault wordpress comments from a plugin
- How to show comments from different Plugins to same post type?
- How to check if `comment_meta` exists before inserting the comment?
- How to get the `comment_post_ID`?
- Email content as comment
- Stop theme displaying comments
- Get Commentor IP When Marking Comment As Spam
- Create pages for authors
- How to set/change another post author by custom fields or something else?
- isset($_POST[‘submit’]) ignored on comment submission
- Need edit profile link in the menu for logged in users
- What are the advantages to the Settings API?
- Changing Plugin Load Order
- How should you hook a session_start() when authoring a plugin?
- Check If comment author is registered
- How to create a plugin that only operates on the home page?
- Adding callback function for wp_ajax_ has no effect
- Create a plugin to change the action to which a function is hooked
- Why is the reset password key missing in the reset password email?
- Paging on a future post loop?
- How to pass custom options from widget form to widget update callback?
- WordPress admin deleted user details not removed in database. How to delete WordPress Users from Database
- plugin development: storing language specific options
- Support auto-save and revisions for custom fields
- Gutenberg – What is the best way to save/update post meta?
- Why do I need to check if wp_nonce_field() exists before using it
- Save Checkbox value in Plugin [duplicate]
- edit_{$taxonomy} | Hook
- Worpdress cannot create directory
- Using the default wordpress uploader inside plugin
- WordPress after content Hook & external template part
- How to associate an existing user to a site in a multisite setup programmatically
- Changing upload dir in a plugin regardless of post type
- WP_Editor – Saving Value into Plugin Option – Stripping HTML
- Commenter should see only his comments in wordpress
- Email verification for new users
- Insert/Update values to a table after blogname option etc. is updated
- Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
- How to add a widget to the post editing view?
- Show message from backend
- Cannot change caption for a plugin
- Remove all removed pages from wordpress
- PHP File_exist() not working – Checking if File Exist in WordPress Theme Directory
- Woocommerce inventory [closed]
- Invalid hook call on save, not edit when using swiper slider
- Change/Set Page Title and Meta Tags from Page Called within a Plugin
- Look for a file in a theme before loading from plugin
- Include HTML (Bootstrap Modal Box) with a plugin into my header
- when i activate my plugin i want to auto create pages with shortcodes
- Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
- How to display TinyMCE HTML view?
- Downloading File via headers doesnt work
- get the permalink error
- Does $this context change in an AJAX callback?
- WordPress custom url without using any of the custom tags given
- How to call a plugin function from a page
- How to prevent users/authors from seing IP/email of new commentators?
- If user is logged-in display/hide widgets ( siteorigine) [closed]
- Javascript not being loaded only in custom taxonomy template
- User Registration Moderate
- Implementing Select2 plugin into WordPress
- Object Oriented plugin, add action and variables
- Why user is added back in database after deletion?
- add_action priority and taxonomy used in plugin
- Variable undefined but it is defined
- Tracing dashboard publish settings from input form in WordPress
- Post data in wp-admin to external database
- Virtual Page with Registration form
- Images not displaying on live server
- redirect word-press page with page values
- How to only Load scripts on variable products page
- Forcing the Uninstall Hook to fail