Skip to:
Content
Pages
Categories
Search
Top
Bottom

Random Avatars for individuals?


  • diversityx
    Participant

    @diversityx

    I have tried most every custom random avatar code here this evening – and the only one I have found to work on my install is the one below. The problem is, that it replaces all the default avatars with a matching random image – and then replaces them again with a new image on a page refresh. I would like to have individual random avatars, per user so they are all different. Is there a loop I need to add to this code to make this happen?

    For some reason, any of the random avatar code I tried that filtered ‘bp_core_mysteryman_src’ would not work at all on this install.

    I am using buddypress 2.2.0

    // Avatar Change
    function bp_custom_set_avatar_constants() {
    
    // Random Images - yet not individual?
    $picid = rand(0, 8); //8 = No. of images
    define( 'BP_AVATAR_DEFAULT', get_stylesheet_directory_uri() . '/images/avatars/avatar'.$picid.'.jpg' );
    define( 'BP_AVATAR_DEFAULT_THUMB', get_stylesheet_directory_uri() . '/images/avatars/avatar'.$picid.'.jpg' );
    
    // Static images
    //   define( 'BP_AVATAR_DEFAULT', get_stylesheet_directory_uri() . '/images/avatar2.jpg' );
    //   define( 'BP_AVATAR_DEFAULT_THUMB', get_stylesheet_directory_uri() . '/images/avatar2.jpg' );
    }
    add_action( 'bp_init', 'bp_custom_set_avatar_constants', 2 );

    Any help would be greatly appreciated!

  • The topic ‘Random Avatars for individuals?’ is closed to new replies.
Skip to toolbar