Skip to:
Content
Pages
Categories
Search
Top
Bottom

Different Style for Key Master and Administrator replies?

Viewing 7 replies - 1 through 7 (of 7 total)

  • Michael
    Participant

    @michael888

    It’s really good idea – and it can be done, but I’m not sure of the code behind it. If it were me, I’d simply do a template edit to get it right; simply by determining the user’s status, and then using a different post CSS class to make it look different.

    Some would suggest a plugin for this however. If I find a way to do it, I will let you know. :)

    My coding really isn’t that advanced yet, so I appreciate the help.


    kevinjohngallagher
    Member

    @kevinjohngallagher

    I have a function for WordPress that outputs some code into the class section of an item:

    e.g. <li class="<?php my_custom_class_ouput_function(); ?>"> comment/thread </li>

    It outputs the user’s level after a specific string (e.g. user_level_5), the author’s name after a string (e.g. author_username_bob ), is the user an author (e.g. user_is_an_author) and if the user is the author of the original thread/blog post (e.g initial_author).

    You can then set up the styles as you want to display them in CSS.

    I’ll have a look at porting this to BBpress later on.


    Gautam
    Member

    @gautam-gupta

    I was working on a plugin, which adds a filter to the delete class and then check if the post is by topic author/mod/admin, but then stopped working on it. I’m thinking to complete that plugin soon.

    Wow, that’s very encouraging. :)

    @gautam, that would be greatly appreciated! :)


    alannascott
    Member

    @alannascott-1

    i had this same issue.

    here’s what i did:

    in /your-theme-folder/topic.php make these changes


    <?php
    //get user id
    $user_id = get_post_author_id();

    //get user role
    $role = get_user_type($user_id);

    // if user is a key master or Administrator add css class
    if ($role == 'Key Master' || $role == 'Administrator') {
    $adminclass = "class='adminpost'";
    }
    //otherwise don't add a class
    else {
    $adminclass = "";
    }
    ?>

    <!--add your css class to the li tag-->
    <li id="post-<?php post_id(); ?>" <?php echo $adminclass; ?>>

    then style your .adminpost class however you’d like.

    hope that helps.

    alanna

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar