• Hi guys,

    I’m setting up a book club for our School and I want to change it so that when people comment it only shows a First name, regardless of whats in their profile.

    For instance, if we have a student with First name: jane, Last name: smith, user name: jsmith90″ in their profile, it should only show “jane” when she comments.

    How can this be done?

    I thought about changing the registration to not ask for a last name (we use Ultimate Member plugin) but we want to be able to see their full name in the backend.

    If it helps, the site is https://endeavoursportshighbookclub.com.au/

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi, could you add a comment on your site (so we can see what the code looks like?)

    An easy way would be to change the display name in account setting to first name. Would that do?

    you could create a child theme with a functions.php file which should contain a function glades_list_comments($comment, $args, $depth) { from a copy of the same function from the parent theme where this line is edited to add just the first name of the comment author:
    <?php printf(__('<span class="fn">%s</span>', 'glades'), get_comment_author_link()) ?>

    for example:

    <?php
    	$url    = get_comment_author_url( $comment->comment_ID );
    	$author = ( $comment->user_id && get_the_author_meta( 'first_name', $comment->user_id ) ? get_the_author_meta( 'first_name', $comment->user_id ) : 'anonymous' );
    
    	if ( empty( $url ) || 'https://' == $url )
    		$author_link = $author;
    	else
    		$author_link = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
    printf(__('<span class="fn">%s</span>', 'glades'), $author_link) ?>

    for further details, please post in your theme’s forum at https://www.ads-software.com/support/theme/glades#postform

    Thread Starter chipped

    (@chipped)

    “An easy way would be to change the display name in account setting to first name. Would that do?”

    Yes, that would be fine. How do I change it for all users though?

    What about future users, is there an option I can set and forget of will I have to change each user manually?

    Cheers

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change Display name for comments’ is closed to new replies.