Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I can display the current user's avatar alongside the comment form when posting a new comment with

$current_user = wp_get_current_user();
if ( ($current_user instanceof WP_User) ) {
  echo get_avatar( $current_user->user_email, 32 );
  }

,but how could I bind the avatar to the comment form if I want to reply to another comment when the onclick addComment.moveForm is fired? The avatar should move along with the form as it moves.

I would be very grateful if someone can point me in the right direction how to dynamically alter the comment form. Documentation on customizing the comment form at Wordpress.org is really poor and I have had a hard time finding any useful info around the internet as well.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

I'll answer myself. Add the following somewhere in functions.php or make it into a plugin:

add_action( 'comment_form_logged_in_after', 'psot_comment_form_avatar' );
add_action( 'comment_form_after_fields', 'psot_comment_form_avatar' );
function psot_comment_form_avatar()
{
  ?>
   <div class="comment-avatar">
     <?php 
     $current_user = wp_get_current_user();
     if ( ($current_user instanceof WP_User) ) {
        echo get_avatar( $current_user->user_email, 32 );
     }
     ?>
   </div>
<?php
}
share|improve this answer
    
Please mark your answer as accepted. –  toscho Dec 28 '13 at 19:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.