Forums

[resolved] Avatars for authors+ only (8 posts)

  1. klaxxe
    Member
    Posted 2 years ago #

    How can I enable avatars for authors, mods, and admins only. I want gravatar avatars to be enabled for authors+ and everyone else to be left blank, is this possible? Or no.

  2. Mark / t31os
    Moderator
    Posted 2 years ago #

    Please provide the code from your theme's template file that deals with displaying gravatars/avatars (likely single.php), just the area relating to the avatar (3-4 lines above, down to 3-4 lines below).

    Also please use a pastebin, or alternatively just ensure code is posted inside backticks as shown in the reply box.
    http://wordpress.pastebin.ca/

    Possible yes, but far easier if i can see the code you have presently..

  3. klaxxe
    Member
    Posted 2 years ago #

    Sorry. Can anyone help me now?
    http://wordpress.pastebin.ca/1682741

  4. Mark / t31os
    Moderator
    Posted 2 years ago #

    I do apologise, it should actually be comments.php or functions.php depending on whether you use a custom callback (function) for comments..

  5. klaxxe
    Member
    Posted 2 years ago #

    Im really not good at this stuff so ill give you both.

    comments.php here

    functions.php here

  6. Mark / t31os
    Moderator
    Posted 2 years ago #

    Figured it would be a custom callback, it was in the functions file.

    Backup first, then replace your functions.php code with the following.
    http://wordpress.pastebin.ca/1683260

    Feel free to examine, i've only made changes to the comments callback function "art_comment"..

    NOTE: Make sure to copy the code from the secondary section that doesn't include the line numbers (further down the page).

    Also when you do, update this area..

    $allowed_avatar = array(
    		'administrator' ,
    		'editor' ,
    		'author' ,
    		'contributor' ,
    		'subscriber'
    	);

    Remove the roles that are NOT allowed avatars. Make sure the last item does not have a comma following (as seen currently with subscriber)..

    For example if you wanted avatars for admin, editor and author only, it would look like so..

    $allowed_avatar = array(
    		'administrator' ,
    		'editor' ,
    		'author'
    	);

    Code was tested under PHP 5, MySQL 4 and using WP 2.8.6.

    Hope that helps.. ;)

  7. klaxxe
    Member
    Posted 2 years ago #

    i love you man. i really do.

  8. Mark / t31os
    Moderator
    Posted 2 years ago #

    Glad i could help.. :)

Topic Closed

This topic has been closed to new replies.

About this Topic