WordPress.org

Ready to get started?Download WordPress

Forums

help with writing a plugin (3 posts)

  1. holographic
    Member
    Posted 9 years ago #

    Bear with me here, I've never tried writing a plugin before...
    I'm trying to write a plugin that will highlight the comment_author where the comment has been posted by a specific email address (ie, comments made by the blog author). I know this can be done easily by editing the coding, but I thought I might try my hand at plugins, because I have nothing better to do at the moment ;)
    So far, I've got it working as a filter on the comment_author hook
    However, if I activate the plugin it adds the span class to every comment author, even those comments posted without an email address.
    here is my function:
    function hilite_author($comment_author) {
    if ($comment_author_email == $youremail) {
    $comment_author="<span class=\"adminhilite\">$comment_author</span>";
    }
    return $comment_author;
    }

    Help!
    Any suggestions would be much appreciated

  2. Stevarino
    Member
    Posted 9 years ago #

    hm.... $comment_author_email isn't set anywhere, did you mean $comment_author? Also $youremail is not set either... Perhaps it should be set at the top of the function? Combine these two facts, and I guess that shows why it's placing span's on every commenter... It evaluates NULL == NULL - which of course is true.

  3. holographic
    Member
    Posted 9 years ago #

    $youremail is set before the function, but forgot to mention that on the original post
    I assumed that $comment_author_email would give the email entered by the comment poster, but perhaps this is wrong. Any idea how I can get the email address of the commenter from the database if this variable doesn't exist?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.