WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Link comments to blog (3 posts)

  1. rec19
    Member
    Posted 5 months ago #

    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 -->
  2. David Sader
    Member
    Posted 5 months ago #

    "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);
    }
  3. rec19
    Member
    Posted 5 months ago #

    This is perfect thanks

Reply

You must log in to post.

About this Topic

Tags

No tags yet.