Help Sought: Do you know WordPress and PHP?


UPDATE: Chip Haynor, Sr. Project Consultant, of CentreSource in Nashville was able to send me the needed code — Thanks Chip!!! Here’s the code: comment_classes.txt. After the “foreach” loop of the comments (should look something like “< ? php foreach ($comments as $comment) : ? >“), enter the code in that text file. The first “if” section checks if the commenter is the post author, and sets the comment class if true (and bypasses the author level check). Otherwise, it checks the author level, and assigns the appropriate term to the $comment_class.

You can add more cases by copying the three lines (the “case”, the “$comment_class” declaration, and the “break;”). As you can see with the case 1 and 2, you can have multiple values for a given declaration (Case 1 AND Case 2 will both become “contrib”).

Then, you just need to put into your HTML code in the appropriate place.

This is a shameless plea for help from my readers — maybe one of you knows WordPress and PHP. If you aren’t a programmer, no need to read any further.

My blog currently highlights any comments I make on my posts differently from regular users — so that they stand-out. I want to take this a step further — WordPress has different user levels and I want to have comments highlighted differently by users in my WordPress that are designated as ‘Contributor’ (user level = 1).

Thus, what I want to do is:
Currently, any of my comments have the following CSS:
class="comment commentOfficialUser"

Whereas normal users’ comments on my site are:
class="comment "

I want to make any user in my WordPress that has a user_level of 1, have the following CSS:
class="comment commentContributorUser"

I currently use the Official Comments plugin. The author references what I’m wanting to do, but he never implemented it into his plugin.

Here is an excerpt of the code from my Template’s “comment” PHP: comments.txt

Thus, you need to grab the user level of the commenter (if they exist in my WordPress as a user; and then check what their user level is — 9 is the admin; 1 is the contributor). Here is the code I thought would work (I removed use of Official Comments all together), but I must be missing something, because it didn’t work — but I think I’m very close with that code.

Otherwise, you could likely modify the Official Comments source code — in an optimal world, it’d be great to have the ability to specify a CSS class for each of the 5 user types in WordPress (Admin, Author, Editor, Contributor, Subscriber).

I sent that code to Rachel and her reply included this, which may help — but I’m not a programmer, so not sure how/where this would fit in.

Feel free to comment in comments if you guys have any input.

Here are some additional resources I found: