Wordpress Highlight comments by multiple Authors.

March 8th, 2010 by admin
1

<![CDATA

IN Comments.php ADD FOLLOWING RIGHT BEFORE FIRST <ol element that contains comment_author_link():

<?php

$users = get_users_of_blog();

foreach( $users as $user ) {

$role = array_pop( array_keys( unserialize($user->meta_value) ) ); // yeah, I know, looks awkward :)

$user_id = $user->user_id;

if ( $role != 'subscriber' ) // collect id of anyone whose role is greater than 'subscriber'

$roles[ $user_id ] = $role;

}

?>

<style>

#commentlist li { border:2px solid white; } /* not logged or subscriber */

#commentlist li.administrator { border:2px solid red } /* blog admin */

#commentlist li.author { border:2px solid blue } /* author */

#commentlist li.editor { border:2px solid yellow } /* editor */

</style>

NOW EDIT THE FIRST <ol ELEMENT WHICH SHOULD LOOK SIMILAR TO:

<ol id=”commentlist”>

<?php foreach ($comments as $comment) : ?>

<li>

<p>By <?php comment_author_link() ?> – <?php comment_date() ?></p>

<?php comment_text() ?>

</li>

<?php endforeach; ?>

</ol>

AFTER ADDING FOLLOWING:

<?php // The extra stuff to get commenter’s role

$user_id = $comment->user_id;

$role = ( isset( $roles[$user_id] ) ? $roles[$user_id] : ” );

?>

class=”<?php echo $role; ?>”

SHOULD LOOK LIKE THIS:

<ol id=”commentlist”>

<?php foreach ($comments as $comment) : ?>

<?php // The extra stuff to get commenter’s role

$user_id = $comment->user_id;

$role = ( isset( $roles[$user_id] ) ? $roles[$user_id] : ” );

?>

<li>

<p>By <?php comment_author_link() ?> – <?php comment_date() ?></p>

<?php comment_text() ?>

</li>

<?php endforeach; ?>

</ol>

CREATE AUTHOR AND SUSBCRIBER USERS IN WORDPRESS ADMIN, WRITE DUMMY COMMENTS AND TEST THAT.

]]>

Post to Twitter Tweet This Post

  • Share/Bookmark
Posted in Uncategorized

One Response to “Wordpress Highlight comments by multiple Authors.”

  1. JACKIE says:


    Medicamentspot.com. Canadian Health&Care.No prescription online pharmacy.Best quality drugs.Special Internet Prices. No prescription drugs. Buy drugs online

    Buy:Viagra Super Active+.Levitra.Soma.Zithromax.Viagra Professional.Cialis Soft Tabs.Viagra Super Force.Cialis Super Active+.Viagra.Tramadol.Maxaman.VPXL.Cialis.Cialis Professional.Super Active ED Pack.Viagra Soft Tabs.Propecia….

Leave a Reply