Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_fetch_avatar'

Viewing 25 results - 201 through 225 (of 251 total)
  • Author
    Search Results
  • omosha
    Participant

    Yeah, I’m still getting the error message
    ‘Warning: Missing argument 5 for bp_core_fetch_avatar_filter() in /home/integral/public_html/wp-content/plugins/buddypress/bp-core/bp-core-avatars.php on line 479’

    and I’ve removed step 3 from https://codex.buddypress.org/getting-started/install-buddypress-on-a-secondary-blog/

    Have you ever run into this or have any idea how to fix?

    Thanks again for checking it out

    omosha
    Participant

    Thank you so much, Mercime! I’ve got most of it all installed with the exception of a few hiccups.

    I had a difficult time with the avatars even before this modification. I’m getting this error code
    ‘/home/integral/public_html/wp-content/plugins/buddypress/bp-core/bp-core-avatars.php on line 479’
    When I go into bp-core-avatars.php on line 479 I see this as the definition:
    ‘function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt ) {

    // If passed an object, assume $user->user_id
    if ( is_object( $user ) )
    $id = $user->user_id;

    // If passed a number, assume it was a $user_id
    else if ( is_numeric( $user ) )
    $id = $user;

    // If passed a string and that string returns a user, get the $id
    else if ( is_string( $user ) && ( $user_by_email = get_user_by_email( $user ) ) )
    $id = $user_by_email->ID;

    // If somehow $id hasn’t been assigned, return the result of get_avatar
    if ( empty( $id ) )
    return !empty( $avatar ) ? $avatar : $default;

    // Let BuddyPress handle the fetching of the avatar
    $bp_avatar = bp_core_fetch_avatar( array( ‘item_id’ => $id, ‘width’ => $size, ‘height’ => $size, ‘alt’ => $alt ) );

    // If BuddyPress found an avatar, use it. If not, use the result of get_avatar
    return ( !$bp_avatar ) ? $avatar : $bp_avatar;
    }’

    I’ve tried installing a bp-custom.php file within the plugin directory so that it would not be deleted when updating Buddypress but it produces an error everywhere on the site.
    Here is what I tried to add as the bp-custom.php file for reference:
    ‘define( ‘BP_AVATAR_UPLOAD_PATH’, ‘/var/www/wp-content/blogs.dir/1/files’ );
    define( ‘BP_AVATAR_URL’, ‘hxxp://integralbeings.com/files’ );’

    As I look at the code, I’m wondering if this is because there is no hxxp://integralbeings.com/files directory. Do I need to add this or is the path incorrect? Also, I’ve not seen hxxp before, is this a typo?

    Thanks for the support on this, it’s rather minor in the grand scheme of things, but I’m wondering if it will become a bigger problem as the community grows.

    Cheers,
    -Brant

    #92253
    Justin Frydman
    Participant

    Thank you both for your help, so I’m hoping I can return the favor. Modemlooper, here is how I adjusted the My Friends tab, but it has sub nav code for you, maybe it will help. Credit for this from @jeffsayre

    `function my_friends_setup_nav() {
    global $bp;

    /* Add ‘Friends’ to the main navigation */
    if( bp_friend_get_total_requests_count($disp_user) > 0 && bp_is_my_profile()) {
    bp_core_new_nav_item( array( ‘name’ => sprintf( __( ‘Friends (%d) (%d)‘, ‘buddypress’ ), friends_get_total_friend_count(), bp_friend_get_total_requests_count() ), ‘slug’ => $bp->friends->slug, ‘position’ => 60, ‘screen_function’ => ‘friends_screen_my_friends’, ‘default_subnav_slug’ => ‘my-friends’, ‘item_css_id’ => $bp->friends->id ) );
    } else {
    bp_core_new_nav_item( array( ‘name’ => sprintf( __( ‘Friends (%d)‘, ‘buddypress’ ), friends_get_total_friend_count() ), ‘slug’ => $bp->friends->slug, ‘position’ => 60, ‘screen_function’ => ‘friends_screen_my_friends’, ‘default_subnav_slug’ => ‘my-friends’, ‘item_css_id’ => $bp->friends->id ) );
    }

    $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . ‘/’;

    /* Add the subnav items to the friends nav item */
    bp_core_new_subnav_item( array( ‘name’ => __( ‘My Friends’, ‘buddypress’ ), ‘slug’ => ‘my-friends’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_my_friends’, ‘position’ => 10, ‘item_css_id’ => ‘friends-my-friends’ ) );
    bp_core_new_subnav_item( array( ‘name’ => sprintf( __( ‘Requests (%d)‘, ‘buddypress’ ), bp_friend_get_total_requests_count() ), ‘slug’ => ‘requests’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_requests’, ‘position’ => 20, ‘user_has_access’ => bp_is_my_profile() ) );

    if ( $bp->current_component == $bp->friends->slug ) {
    if ( bp_is_my_profile() ) {
    $bp->bp_options_title = __( ‘My Friends’, ‘buddypress’ );
    } else {
    $bp->bp_options_avatar = bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘type’ => ‘thumb’ ) );
    $bp->bp_options_title = $bp->displayed_user->fullname;
    }
    }

    do_action( ‘friends_setup_nav’ );
    }

    add_action( ‘bp_setup_nav’, ‘my_friends_setup_nav’, 11 );`

    #90139

    In reply to: group default avatar

    r-a-y
    Keymaster

    Since you’re using the filter I posted, I would manually setup a group loop. Then in this loop, I would use the bp_core_fetch_avatar() function with the “html” parameter set to false (view the full function and parameter list in /bp-core/bp-core-avatars.php).

    Doing this will return the URL of the avatar, then you can manually define the width and height in an IMG tag.

    #90093
    r-a-y
    Keymaster

    seobrien –
    Read this: http://wpmu.org/how-to-add-a-custom-default-avatar-for-buddypress-members-and-groups/

    iamnorthwind –
    If you’re using another plugin to upload avatars, you’ll need to override the way BuddyPress fetches avatars.

    Specifically, you’ll need to override the “bp_core_fetch_avatar” filter located in /buddypress/bp-core-avatars.php file.

    Need a primer on filters? Read this:
    https://codex.wordpress.org/Plugin_API#Filters

    warut
    Participant

    @Pisanojm here are temp solution. However I see your extend profile not show in badge, I will check that too but in about 3 days (no computer in my new home – -“).

    temp solution:

    — replace —

    if ( get_site_option(‘bp_badge_showthumbimage’) == true ) {
    $avatar_html = bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘type’ => ‘thumb’, ‘alt’ => __( ”, ‘buddypress’ ) ) );
    } else {
    $avatar_html = bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘type’ => ‘full’, ‘alt’ => __( ”, ‘buddypress’ ) ) );
    }
    preg_match_all(“//i”, $avatar_html, $avatar_url);

    — with —

    if ( get_site_option(‘bp_badge_showthumbimage’) == true ) {
    $avatar_url = bp_get_loggedin_user_avatar( ‘html=false&type=thumb’ );
    } else {
    $avatar_url = bp_get_loggedin_user_avatar( ‘html=false&type=full’ );
    }


    and


    search “$avatar_url[2][0]” replace with “$avatar_url”

    for others i will try upload new release next week.

    #89393

    In reply to: Gravatar Settings?

    Roger Coathup
    Participant

    @lunakm: rather than modifying the core code, which will need changing every time BP is upgraded, you might be better trying to do it as a filter.

    I suspect the filter you’d want to work with is bp_core_fetch_avatar_url. Try hooking a function onto this (in your bp-custom.php file) that appends the &r=x to the url.

    It might be worth raising it as an enhancement request for future BP releases, to give more control over the parameters that can be passed to Gravatar.

    Cheers, Roger

    r-a-y
    Keymaster

    To remove FB avatars from the FB plugin, add the following to your theme’s functions.php:
    remove_filter( 'bp_core_fetch_avatar', 'jfb_get_facebook_avatar', 10, 4 );

    To have an option between either the BP avatar and the FB avatar, some custom code would be needed to display an admin option in the user’s settings page.

    #87553
    techguy
    Participant

    @odiggy Try the Donate button on one of r-a-y’s plugins: https://buddypress.org/community/groups/oembed-for-buddypress/

    r-a-y, Thanks for the extra answer. I started trying to document some of the bp_core_fetch_avatar function so that I could add it to the codex: https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/changing-avatar-size-sometimes-creates-fuzzy-avatars/ This is a good addition.

    #87509
    r-a-y
    Keymaster

    @odiggy – You could also use:
    bp_loggedin_user_avatar( 'html=false' );
    (available in /bp-core/bp-core-templatetags.php)

    Because that will automatically call the logged in user’s avatar without using the generic bp_core_fetch_avatar() and needing additional parameters.

    #87405
    katemgilbert
    Participant

    Here is the code on line 479 (referenced in error):

    function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt ) {

    #87398
    odiggy
    Participant

    Thanks for your reply!

    Using bp_core_fetch_avatar( array( ‘html’ => false ) ) but still not quite working, do I need to call the logged in user id somehow along with this?

    #87391
    r-a-y
    Keymaster

    Use bp_core_fetch_avatar() and pass the “html” argument as false.

    Check out bp_core_fetch_avatar() @ /bp-core/bp-core-avatars.php.

    justbishop
    Member

    OK, I found this in bp-core-adminbar.php. Say I wanted to get rid of the text “Blog Authors”, but only for blog ID# 12:

    // **** “Blog Authors” Menu (visible when not logged in) ********
    function bp_adminbar_authors_menu() {
    global $bp, $current_blog, $wpdb;

    if ( $current_blog->blog_id == BP_ROOT_BLOG || !function_exists( ‘bp_blogs_install’ ) )
    return false;

    $blog_prefix = $wpdb->get_blog_prefix( $current_blog->id );
    $authors = $wpdb->get_results( “SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = ‘{$blog_prefix}capabilities’ ORDER BY um.user_id” );

    if ( !empty( $authors ) ) {
    /* This is a blog, render a menu with links to all authors */
    echo ‘

  • ‘;
    _e(‘Blog Authors’, ‘buddypress’);
    echo ‘
    ‘;

    echo ‘

    ‘;
    echo ‘

  • ‘;
    }
    }

#86824
techguy
Participant

So, I haven’t figured all of bp_core_fetch_avatar() out, but here’s some of the types:
type=thumb
type=full

Interestingly, the code I pasted in my previous post took the thumbnail image, but displayed it the size of the full (150×150 I think). So, it was pixelated and ugly. So, I changed it to type=full and it’s a nice 150×150 image.

If anyone else can explain the rest, this seems like some good content for the codex.

#86821
techguy
Participant

I’ve been trying to get it to pull various size group avatars and haven’t had much luck. Here’s the code I’m using:
$avatar = bp_core_fetch_avatar( array( ‘item_id’ => $group->id, ‘object’ => ‘group’, ‘type’ => $type, ‘avatar_dir’ => ‘group-avatars’, ‘alt’ => $alt, ‘css_id’ => $id, ‘class’ => $class, ‘width’ => $width, ‘height’ => $height ) );

Shouldn’t I just be able to pass the width and height values that I want? Am I only allowed to pass in certain width and height values? Seems like I could also pass in $type and that could give me the various sizes?

Also, this passes the full HTML for the image. Is there a way I could just get the URL of the image? I could rip it out of the HTML, but that’s kind of messy.

#86753
Brajesh Singh
Participant

@crashutah
That’s a good point. Incase we want different size for groups and members the only good way is to override the “bp_core_avatar_handle_crop” and may be in extreme case “bp_core_avatar_handle_upload” and that will give you enormous flexibility.
After overriding it, we can filter on “bp_core_fetch_avatar” and that will be all we need.

#86720
techguy
Participant

@sbrajesh It seems like the group avatar’s use this same code. How would you call the bp_core_fetch_avatar of varying sizes for groups by group id?

#86627
Brajesh Singh
Participant

well, The very first thing is
1. define the 2 size(bp allows only 3 sizes of avatar at this moment) using the constants BP_AVATAR_(THUMB/FULL/ORIGINAL_MAX)_HEIGHT and BP_AVATAR_(THUMB/FULL/ORIGINAL_MAX)_WIDTH if the original avatar sizes(50×50,150×150,450×450) does not fit your requirement.

Then use bp_core_fetch_avatar, it supports the width,height property and thumb type
You can fetch an avatar of different size using different width/height value but again, It will not crop, it will constrain the avar using the width/height property in the img tag. so i don’t think it will be of much use .

But if you want only 2 sizes of avatar, as you mentioned above, define one as Thumb,other as full and fetch thumb using “type=thumb” and the other using “type=anything other than thumb” in bp_core_fetch_avatar and it will work.

#85548
vsimovic
Member

Ok, i’ve managed to do it with:
global $bp;
bp_core_fetch_avatar( array( ‘item_id’ => $id, ‘type’ => ‘full’, ‘width’ => ’75’, ‘height’ => ’75’, ‘html’ => ‘false’ ) )

If somebody needs the same thing he can try this lines, maybe it will help. :)

#84211
Justin Frydman
Participant

Well,

I tried remove_action on the function I found that I want to customize, but it doesn’t work apparently because bp-custom.php is being loaded before bp-friends. I tried this in my theme’s functions.php as well, but it still does not work. What am I doing wrong?

/***
* Create custom functions for buddypress so updates do not override customizations
*/

function my_friends_setup_nav() {
global $bp;

/* Add ‘Friends’ to the main navigation */
bp_core_new_nav_item( array( ‘name’ => sprintf( __( ‘Friends (%d)2222′, ‘buddypress’ ), friends_get_total_friend_count() ), ‘slug’ => $bp->friends->slug, ‘position’ => 60, ‘screen_function’ => ‘friends_screen_my_friends’, ‘default_subnav_slug’ => ‘my-friends’, ‘item_css_id’ => $bp->friends->id ) );

$friends_link = $bp->loggedin_user->domain . $bp->friends->slug . ‘/’;

/* Add the subnav items to the friends nav item */
bp_core_new_subnav_item( array( ‘name’ => __( ‘My Friends’, ‘buddypress’ ), ‘slug’ => ‘my-friends’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_my_friends’, ‘position’ => 10, ‘item_css_id’ => ‘friends-my-friends’ ) );
bp_core_new_subnav_item( array( ‘name’ => __( ‘Requests’, ‘buddypress’ ), ‘slug’ => ‘requests’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_requests’, ‘position’ => 20, ‘user_has_access’ => bp_is_my_profile() ) );

if ( $bp->current_component == $bp->friends->slug ) {
if ( bp_is_my_profile() ) {
$bp->bp_options_title = __( ‘My Friends’, ‘buddypress’ );
} else {
$bp->bp_options_avatar = bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘type’ => ‘thumb’ ) );
$bp->bp_options_title = $bp->displayed_user->fullname;
}
}

do_action( ‘my_friends_setup_nav’);
}
remove_action( ‘bp_setup_nav’, ‘friends_setup_nav’);
add_action( ‘bp_setup_nav’, ‘my_friends_setup_nav’);

#83552

1.2.5 has an almost totally rewritten bp_core_fetch_avatar function that should fix these issues. Can you confirm that all files are up to date and try again?

#82218

In reply to: Show specific avatar

Brandon Allen
Participant

The user_id argument doesn’t exist because there is no user_id argument. The argument that accepts a user id is the item_id argument as I stated above. Try this:

echo bp_core_fetch_avatar( array( ‘width’ => 30, ‘height’ => 30, ‘item_id’ => 1 ) );

If all you need is the thumbnail, then you don’t need the ‘type’ argument, as it defaults to thumbnail.

#82037

In reply to: Show specific avatar

LPH2005
Participant

Thank you. Since I’m not good with php, my interpretation doesn’t seem to work. This is the echo statement to get the avatar to show, however, I’m not sure that the user_id argument works. The area for this statement is blank.

echo bp_core_fetch_avatar(‘type=thumb&width=30&height=30&user_id=1’);

#82011

In reply to: Show specific avatar

Brandon Allen
Participant

Have a look at bp_core_fetch_avatar(). It accepts a number of arguments you’ll want to explore for your use case. The most important being $item_id, which in your case would be your user id number and that user id of your teacher.

Viewing 25 results - 201 through 225 (of 251 total)
Skip to toolbar