• Using twenty eleven and twenty eleven child themes:

    To ensure privacy of my commenters, how can I make a default where John Doe makes a comment and his name appears as John D. ?

    I can’t find any help for this, but some are close. As it is, I am changing the last names manually after the fact.

    Would this be something that can be done in the child theme?

    BTW–please don’t reply with a “Yes, that can be done.” 🙂

    Thanks,

    Bob

Viewing 4 replies - 1 through 4 (of 4 total)
  • Does your comment form ask for first name and last name initial as two separate fields with the character length of the last name initial field limited to one?

    http://php.net/mb_substr

    Thread Starter myRobertForums

    (@myrobertforums)

    Here’s my URL: http://my-neighborhoods.net

    Right now there are four fields, with * indicating required:

    Name: *
    Email: *
    Website:
    Comment:

    So, there’s only a single field for any name people want to use.

    I’ve made another Post asking how to add text under the Leave a Reply heading: http://wordpress.org/support/topic/adding-text-to-comment-box-heading?replies=2

    This would be just as useful for me.

    Thanks,

    Bob

    Twenty Eleven uses a pluggable callback function to show the comments, so you can create a copy of it in functions.php of your child theme, and edit it;

    the function code starts with:
    function twentyeleven_comment( $comment, $args, $depth ) {

    you will need to copy the full function into functions.php of the child theme.

    you could then rewrite this section of the code:

    /* translators: 1: comment author, 2: date and time */
    						printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
    							sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
    							sprintf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
    								esc_url( get_comment_link( $comment->comment_ID ) ),
    								get_comment_time( 'c' ),
    								/* translators: 1: date, 2: time */
    								sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )
    							)
    						);

    for example with:

    // shorten last name of comment author to one initial //
    	$url    = get_comment_author_url( $comment_ID );
    	$author = get_comment_author( $comment_ID );
    	$author_parts = explode( ' ', $author );
    	if( count( $author_parts ) >1 ) {
    		$author_last = array_pop( $author_parts );
    		$author_last = substr( $author_last, 0, 1) . '.';
    		array_push( $author_parts, $author_last );
    		$author = implode( ' ', $author_parts );
    		}
    	if ( empty( $url ) || 'http://' == $url )
    		$comment_author_link = $author;
    	else
    		$comment_author_link = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
    
    						/* translators: 1: comment author, 2: date and time */
    						printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
    							sprintf( '<span class="fn">%s</span>', $comment_author_link ),
    							sprintf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
    								esc_url( get_comment_link( $comment->comment_ID ) ),
    								get_comment_time( 'c' ),
    								/* translators: 1: date, 2: time */
    								sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )
    							)
    						);

    http://codex.wordpress.org/Template_Tags/get_comment_author_link

    not widely tested

    Thread Starter myRobertForums

    (@myrobertforums)

    Thanks, again, Alchymyth

    After looking over all of this, I think the easiest way is to simply add text above the reply box to the effect of giving the commenter the option to use last name or initial. Here’s another post I made which, of course, is another question, though related.

    Just under the Leave a Reply heading above the Comments box is the following text:
    Your email address will not be published. Required fields are marked *

    How can I add text to this, possibly even adding a third line?

    Searching my entire blog, I found:
    Your email address will not be published.

    but not:
    Required fields are marked

    in blog\wp-includes\comment-template.php

    Just about every response recommends making changes to the child theme only, which I have and use.

    Where and how can I add the additional text?

    I want it to state:
    Your email address will not be published. Required fields are marked *
    Last Name is mandatory.
    (not in italic)

    Thanks,

    Bob

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Comments: how to show first name and first initial of last name’ is closed to new replies.