Support » Networking WordPress » Link comments to blog

  • Resolved rec19

    (@rec19)


    I recently asked if it was possible to have all blogs set to ‘users must register to comment’ by default in settings/discussions which works great.

    As I have done this, is it also possible to add another code in an mu-plugin that links each comment to that persons blog? So all author names (and if possible, author avatars) are linked to their blog homepage.

    I have found the following code in comment-template.php if it helps, don’t know what to do with it though:

    protected function html5_comment( $comment, $depth, $args ) {
    		$tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
    ?>
    		<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>>
    			<article id="div-comment-<?php comment_ID(); ?>" class="comment-body">
    				<footer class="comment-meta">
    					<div class="comment-author vcard">
    						<?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
    						<?php printf( __( '%s <span class="says">says:</span>' ), sprintf( '<b class="fn">%s</b>', get_comment_author_link() ) ); ?>
    					</div><!-- .comment-author -->
Viewing 2 replies - 1 through 2 (of 2 total)
  • “add another code in an mu-plugin that links each comment to that persons blog?”

    I offer this snippet in an mu-pluigins to get you part of the way there:

    add_filter('get_comment_author_url', 'ds_comment_author_link');
    
    function ds_comment_author_link($url) {
    	global $comment;
    
            if ( empty ( $comment )
                or ! is_object( $comment )
                or empty ( $comment->comment_author_email )
                or ! $user = get_user_by( 'email', $comment->comment_author_email )
                or ! $details = get_active_blog_for_user($user->ID)
            )
            {
                return $url;
            }	
    
    	return get_blogaddress_by_id($details->blog_id);
    }
    Thread Starter rec19

    (@rec19)

    This is perfect thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Link comments to blog’ is closed to new replies.