BuddyDev

Search

[Resolved] Custom avatar by type

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #18141

    Hi CDS,
    I believe that Kleo is overriding the default avatar and that’s why it is happening. Can you please ask them if they are doing it?

  • Participant
    Level: Initiated
    Posts: 12
    CDS on #18264

    Hi Brajesh,
    Unfortunatly I connot contact the Kleo team because I don’t have the purchase code to do that (the theme was bought by the customer and I cannot join him actually)
    So I looked into all php file and Found in WP>plugins>buddypress>bp-core the bp-core-avatars.php where the mystery man is managed.
    The code is :
    ‘/**
    * Filters whether or not to skip Gravatar check.
    *
    * @since 1.5.0
    *
    * @param bool $value Whether or not to skip Gravatar.
    * @param array $params Array of parameters for the avatar request.
    */
    if ( ! apply_filters( ‘bp_core_fetch_avatar_no_grav’, $params[‘no_grav’], $params ) ) {

    // Set gravatar type.
    if ( empty( $bp->grav_default->{$params[‘object’]} ) ) {
    $default_grav = ‘wavatar’;
    } elseif ( ‘mystery’ == $bp->grav_default->{$params[‘object’]} ) {

    /**
    * Filters the Mystery person avatar src value.
    *
    * @since 1.2.0
    *
    * @param string $value Avatar value.
    * @param string $value Width to display avatar at.
    */
    $default_grav = apply_filters( ‘bp_core_mysteryman_src’, ‘mm’, $params[‘width’] );
    } else {
    $default_grav = $bp->grav_default->{$params[‘object’]};
    }

    // Set gravatar object.
    if ( empty( $params[’email’] ) ) {
    if ( ‘user’ == $params[‘object’] ) {
    $params[’email’] = bp_core_get_user_email( $params[‘item_id’] );
    } elseif ( ‘group’ == $params[‘object’] || ‘blog’ == $params[‘object’] ) {
    $params[’email’] = $params[‘item_id’] . ‘-‘ . $params[‘object’] . ‘@’ . bp_get_root_domain();
    }
    }’

    What do you think about ? Is it possible to delete that and add your code at the place ?

    Thanks for your help … and your patience !

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #18269

    Hi CDS,
    Please search for add_filter in your theme and then check if there is any filter attached to some avatar hook? I do have access to old kleo theme since I worked with it on for a client in past, I will check the same early next week too. But if you can provide the details earlier, that will be better.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 12
    CDS on #18278

    Thanks for your reply !
    I’ll look for that but where ?

    In waiting, I deleted the elsif about the mystery man in bp-core-avatars.php.
    Now it’s the default avatar from http://www.gravatar.com displayed.

    I tried to get your code in bp-custom.php and this file in the plugins root but I have a blank page if I add ‘<?php’ at the start. Or the code is displayed without ‘<?php’

    In Kleo directory, there is a buddypress repertory wich contents a buddypress-functions.php where I found
    ‘// Template Output.
    add_filter( ‘bp_get_activity_action_pre_meta’, array( $this, ‘secondary_avatars’ ), 10, 2 );’

    In functions.php there isn’t no add_filter attached to some avatar hook, just this one for your code.
    And of course there are a few add_filter in bp-core-avatars.php

    Perhaps it’s not suffisant to put your code in functions.php ? But how can I do a bp-custom.php without blank page ?

    A very big thank you !

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #18281

    Hi CDS,
    Are you using some tool/ide to search for the code. If yes, you should search in wp-content/themes/kleo

    About the changed file, you can revert by replacing the file with the non modified from current buddypress version(fresh download).

    Can you please use pastebin to share what you are putting in bp-custom.php, That will give me an idea why it is causing blank screen.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 12
    CDS on #18291

    I simply open php file and search with the search tool.

    In Themes > kleo > buddypress > members > members-loop.php I think to have found the code displaying the list of members in a group because it’s the same in the Inspector
    :
    ‘ <li class=”kleo-masonry-item”>
    <div class=”member-inner-list animated animate-when-almost-visible bottom-to-top”>
    <div class=”item-avatar rounded”>
    “><?php bp_member_avatar(); ?>
    <?php do_action(‘bp_member_online_status’, bp_get_member_user_id()); ?>
    </div>’

    This is the link to pastebin https://pastebin.com/DhUzb5bd

    I continue to search in other files in kleo

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #18323

    Hi CDS,
    I will suggest using Some IDE to search as that will make it super easy to find it for you.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 1
    Slaven Beram on #24923
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #24924

    Hi Slaven,
    Welcome to BuddyDev.

    Please open a new topic with details and we will assist. My private replies here won’t be visible to you as the topic author is someone else.

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #29504

    I am closing this topic as resolved due to age of the topic. Also, BuddyPress Member Types pro now provides the ability to set gender based(where gender are your member type) default avatars/covers.
    https://buddydev.com/plugins/buddypress-member-types-pro/

    Regards
    Brajesh

The topic ‘ [Resolved] Custom avatar by type’ is closed to new replies.

This topic is: resolved