Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_fetch_avatar'

Viewing 25 results - 126 through 150 (of 310 total)
  • Author
    Search Results
  • #178036
    Henry Wright
    Moderator

    Hi

    Try:

    echo bp_core_fetch_avatar( array( 
        'alt' => 'Profile picture of ' . bp_get_loggedin_user_fullname(),
        'class' => 'avatar', 
        'width' => 50, 
        'height' => 50, 
        'item_id' => bp_loggedin_user_id(), 
        'type' => 'full', 
        'title'=> bp_get_loggedin_user_fullname()
    ) );
    Conor "DUNKYMONKEY"
    Participant

    Hi I am developing a new site for a client. I’m trying to crate a sidebar for logged in users with their avatar, username, notifications and the Buddypress pages. I’m trying to add the avatar with the code below:

    <?php
    $userid = bp_loggedin_user_id();
    $avatarurl = bp_core_fetch_avatar( array( ‘item_id’ => $userid, ‘html’ => false ) );
    echo $avatarurl;
    ?>

    This works on Buddypress profile page but no other page, is there anything I need to include in the header. This is a personal theme not the Buddypress default. I’m using WordPress 3.8.1 and Buddypress 1.9.2. The site is beta.hyperjake.com

    Thanks for your help
    Conor

    Conor "DUNKYMONKEY"
    Participant

    Hi I am developing a new site for a client. I’m trying to crate a sidebar for logged in users with their avatar, username, notifications and the Buddypress pages. I’m trying to add the avatar with the code below:

    <?php
    $userid = bp_loggedin_user_id();
    $avatarurl = bp_core_fetch_avatar( array( ‘item_id’ => $userid, ‘html’ => false ) );
    echo $avatarurl;
    ?>

    This works on Buddypress profile page but no other page, is there anything I need to include in the header. This is a personal theme not the Buddypress defult.

    Thanks for your help
    Conor

    #177518
    Marcella
    Participant

    I have 2 loops in the sidebar on a group page.

    
    <?php if(bp_has_members('&include='. bp_group_admin_ids())) : ?>			
    	<?php while(bp_members()) : bp_the_member(); ?>
    		<li>
    			<a href="<?php bp_member_permalink(); ?>">
    				<div class="thumb">
    				<?php echo bp_core_fetch_avatar(array('item_id' => bp_get_member_user_id(), 'type' => 'thumb', 'width' => 40, 'height' => 40, 'alt' => sprintf(__('Profile picture of %s', 'buddypress'), bp_get_member_name()))); ?>
    				</div>
    				<div class="details">
    					<strong><?php bp_member_name(); ?></strong>
    					<em><?php bp_member_last_active(); ?>
    				</div>
    			</a>
    		</li>
    	<?php endwhile; ?>				
    <?php else : ?>
    	<li>No administrators in this group.</li>
    <?php endif; ?>
    

    and

    
    <?php if(bp_group_has_moderators()) : ?>			
    	<?php if(bp_has_members('&include=' . bp_group_mod_ids())) : ?>			
    		<?php while(bp_members()) : bp_the_member(); ?>
    			<li>
    				<a href="<?php bp_member_permalink(); ?>">
    					<div class="thumb">
    					<?php echo bp_core_fetch_avatar(array('item_id' => bp_get_member_user_id(), 'type' => 'thumb', 'width' => 40, 'height' => 40, 'alt' => sprintf(__('Profile picture of %s', 'buddypress'), bp_get_member_name()))); ?>
    					</div>
    					<div class="details">
    						<strong><?php bp_member_name(); ?></strong>
    						<em><?php bp_member_last_active(); ?>
    					</div>
    				</a>
    			</li>
    		<?php endwhile; ?>				
    	<?php endif; ?>
    <?php else : ?>
    	<li>No moderators in this group.</li>
    <?php endif; ?>
    

    Neither of these loops output anything, even though they are the same as that found in groups/single/admin.php

    Any ideas?

    Thanks

    #176486
    Henry
    Member

    Not saying this is the problem because I have very limited PHP knowledge but maybe that’s where echo bp_core_fetch_avatar( array(… is getting it’s Avatar from.

    I can’t seem to duplicate the problem. It actually works for me.

    Can you try using Twenty Thirteen? If that works then that shows something has been introduced (perhaps in your theme or maybe a plugin) which is conflicting with the function.

    #176483
    Shmoo
    Participant

    No not really, the only places where I’ve changed the avatar sizes is inside BP page templates like this,

    
    <?php bp_the_thread_message_sender_avatar( 'type=thumb&width=64&height=64' ); ?>
    ....
    <?php bp_loggedin_user_avatar( 'type=thumb&height=64&width=64' ); ?>
    ....
    <?php bp_member_avatar( 'height=192&width=192' ); ?>
    ....
    <?php bp_displayed_user_avatar('type=full&height=192&width=192'); ?>
    

    I’m using functions.php to add custom codes, but no avatar related code inside that.

    I did a search at bp_core_fetch_avatar and found this at bp-core-tamplet.php

    
    /**
     * Output a post author's avatar.
     *
     * Not currently used in BuddyPress.
     *
     * @todo Deprecate.
     */
    function bp_post_author_avatar() {
    	global $post;
    
    	if ( function_exists( 'bp_core_fetch_avatar' ) )
    		echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb', 'alt' => sprintf( __( 'Avatar of %s', 'buddypress' ), bp_core_get_user_displayname( $post->post_author ) ) ) ) );
    	else if ( function_exists('get_avatar') )
    		get_avatar();
    }
    

    This is the first time I can track bp_core_fetch_avatar as a function combined with an array() and look there is no width and height inside that array only thumb and alt.

    Not saying this is the problem because I have very limited PHP knowledge but maybe that’s where echo bp_core_fetch_avatar( array(… is getting it’s Avatar from.

    #176462
    Shmoo
    Participant

    This code is part of bp-messages-tample.php and it handles the Users list inside the send-to autocomplete pop-up ( compose msg )

    But if you change ‘width’ => 15 to ‘width’ => 32 is doesn’t apply and just keeps giving 15px avatar width front-end.

    
    function bp_message_get_recipient_tabs() {
    	$recipients = explode( ' ', bp_get_message_get_recipient_usernames() );
    
    	foreach ( $recipients as $recipient ) {
    		$user_id = bp_is_username_compatibility_mode() ? bp_core_get_userid( $recipient ) : bp_core_get_userid_from_nicename( $recipient );
    
    		if ( $user_id ) : ?>
    
    			<li id="un-<?php echo esc_attr( $recipient ); ?>" class="friend-tab">
    				<span><?php
    					echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) );
    					echo bp_core_get_userlink( $user_id );
    				?></span>
    			</li>
    
    		<?php endif;
    	}
    }
    
    Jake
    Participant

    Wanted to add different color borders around admin avatars, moderators, premium members, free members, etc to allow for easy identification of community roles. Unfortunately there are no CSS selectors in the avatars natively to do this…

    As a solution I updated the function bp_get_member_avatar(), it now gives an ID to each avatar depending on the user’s role/capabilities

    	function bp_get_member_avatar( $args = '' ) {
    		global $members_template;
    
    		$fullname = !empty( $members_template->member->fullname ) ? $members_template->member->fullname : $members_template->member->display_name;
    
    		$defaults = array(
    			'type'   => 'thumb',
    			'width'  => false,
    			'height' => false,
    			'class'  => 'avatar',
    			'id'     => false,
    			'alt'    => sprintf( __( 'Profile picture of %s', 'buddypress' ), $fullname )
    		);
    		//START EDIT HERE
    		$user = get_user_by('login', $members_template->member->user_login); //RETREIVE WP USER OBJECT
    						if($user){
       							if (user_can($user,'edit_users')){ //CHECK USER CAPABILIRY
    								$defaults['id'] = 'admin_avatar'; //ASSIGN ID BASED OFF USER ROLE
    							} 
    							elseif (check_role($user->ID,'moderator')){//CHECK USER ROLE
    								$defaults['id']  = 'mod_avatar';
    							}
    							elseif (user_can($user,'premium_member')){
    								$defaults['id']  = 'prem_avatar';
    							}
    							else {
    								$defaults['id'] ='free_avatar';
    							}
    						}
    
    		$r = wp_parse_args( $args, $defaults );
    		extract( $r, EXTR_SKIP );
    
    		return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
    	}
    

    Note: This can be made much more flexible by turning it into it’s own function, but I have no need for that right not (lots of other stuff to configure).

    #174707
    mattg123
    Participant

    @pjbursnall , I wouldn’t say that it is pretty easy here

    <?php global $current_user;
    		get_currentuserinfo();
    		$display = $current_user->display_name;
    		$login = $current_user->user_login;
    		$userid = $current_user->ID;
                    $home = get_home_url();
    ?>

    add that above your custom drop-down then its pretty simple just echo out the username, url etc <li class="li-fourth"><a href="<?php echo $home . '/members/' . $login . '/activity/mentions'; ?>">Mentions</a></li>

    EDIT –

    Oh the other bit you’d have to google for is the avatar but here
    <?php echo bp_core_fetch_avatar( array('item_id' => $userid, 'type' => 'full', 'width' => 100,'height' => 100));?>
    You’ll want to adjust the width/height accordingly

    gunn4r
    Participant

    I use the PODs CMS framework plugin to add a bunch of custom user meta fields including an avatar field. All of my users will be registered manually and their avatars will be set when they are created. I want to use the avatars I set through PODs instead of the buddypress avatar (which because I have disabled gravatars, is the default mystery man).

    With PODs if I call get_avatar() it pulls in the avatar I upload.

    I have been up and down the bp-core-avatars file and looked at the filters for bp_core_fetch_avatar and bp_core_fetch_avatar_url and I can’t seem to get anything to work.

    Before I put my fist through my monitor, I’d love to see if anyone can help me with this issue. Not sure why it’s so difficult, it seems like it should be easy… (frankly BP should just look to see if theres a non-default avatar WP avatar through get_avatar and if so, use that.)

    Thanks.

    #170843
    aleciri83
    Participant

    add_filter('bp_core_fetch_avatar_no_grav', '__return_true');

    #170734
    catyco
    Participant

    I am using the below function to check for Avatar. However the else condition is displaying when users are logged in via social media (FB, Twitter) and they have a profile picture. How can I ignore them? or how can I get their picture to download to the avatar directly

    function user_has_avatar(){
    global $bp;

    if ( bp_core_fetch_avatar( array( ‘item_id’ => $bp->loggedin_user->id, ‘no_grav’ => true,’html’=> false ) ) != bp_core_avatar_default() ){

    echo ‘Gravatar exists’;
    }
    else { echo ‘Neither avatar nor Gravatar exist.’;
    }
    }
    ?>

    #170656
    Hugo Ashmore
    Participant

    to get the authors BP account url you could try:

    bp_core_get_user_domain( get_the_author_meta( ‘ID’ )

    In the same vein you should be able to grab the BP avatar:

    bp_core_fetch_avatar( array(‘item_id’ => get_the_author_meta( ‘ID’ )

    #170434
    Skeary
    Participant

    I have a multisite installation where the main site () has buddypress and all the profiles, avatars etc.

    On one of the subsites (subsite.mydomain.com), which is set up in a wordpress multisite network, I need to be able to get the buddypress user info from the main site, but buddypress is not installed. I’m able to write custom queries to pull back what I need from the profiles, but the avatar is more complicated. I will be able to duplicate much of what is in the 300 lines long bp_core_fetch_avatar() function I supposed, but I’m wondering if there would be a more straightforward solution to this problem.

    Could I even enable buddypress on the subsites but not actually have any links to the pages anywhere just to get the user profile information? I believe it uses the same database over multisite installations.. is that correct?

    #170090
    Hugo Ashmore
    Participant

    Please do not advise the editing of core files this is poor practise and never recommended.

    You describe the default args there, the correct means of changing those is when using bp_core_fetch_avatar() to pass it an array of values.

    In templates adjust the various avatar calls using similar principle

    mathieu.urstein
    Participant

    @modemlooper

    thank you the problem was the quotes 😉

    modemlooper
    Moderator
    <?php
    $userid = bp_loggedin_user_id();
    $avatarurl = bp_core_fetch_avatar( array( ‘item_id’ => $userid, ‘html’ => false ) );
    echo $avatarurl;
    ?>

    rewrite the quote marks, if you cut and paste it can have funky formatting. If you want to display the avatar instead of getting link:

    <?php
    $userid = bp_loggedin_user_id();
    echo bp_core_fetch_avatar( array( ‘item_id’ => $userid) );
    ?>
    mathieu.urstein
    Participant

    thank you @modemlooper

    I did :

    $userid = bp_loggedin_user_id();
    $avatarurl = bp_core_fetch_avatar( array( ‘item_id’ => $userid, ‘html’ => false ) );

    But the problem is still the same,
    what did I do wrong?

    Thanks.

    modemlooper
    Moderator

    $id = //pass the id of a user
    bp_core_fetch_avatar( array( ‘item_id’ => $id, ‘html’ => false ) );

    If you are not on a user page then you must tell it what id of the avatar to get.

    bp_displayed_user_id
    bp_loggedin_user_id

    mathieu.urstein
    Participant

    I’m using the
    bp_core_fetch_avatar( array( 'html' => false ) );
    code.

    But it only works when i’m on buddypress generated page.

    How can I make it work everywhere on my website?

    #166817
    mattg123
    Participant

    @applegateian, henries code should work, but as you’ve experienced it won’t change the current size of the avatars. I also believe bp has thumbnail avatars and “full” the smaller “thumbnail” the ones wordpress uses is 50px and the larger(which can be grabbed with bp_core_fetch_avatar) are 150px by 150px.

    bp_core_fetch_avatar( array(
        'item_id' => $userid,
        'type'     => 'full',
        'width'    => 150,
        'height'  => 150
    ));

    That will display the “full” avatar.

    #166754
    Henry
    Member

    BuddyPress seems to attempt to filter get_avatar() – see bp_core_fetch_avatar_filter(). I did bring this issue up a while ago at WordPress Trac but the call was closed.

    https://core.trac.wordpress.org/ticket/24596

    Wonder if anyone thinks it’s worthy of a BP Trac ticket?

    #166723
    applegateian
    Participant

    Ah ok thanks, this code doesn’t seem to return anything, can you help me with the error?

     <a href="/community/members/<?php echo get_the_author_meta('user_login') ?>"> <?php echo bp_core_fetch_avatar ( get_the_author_meta('user_email'), $size = '192' ); ?>
    </a>
    #166683
    mattg123
    Participant

    You’re using wordpress’s get_avatar, bp_core_fetch_avatar is what you’re looking for

    Eugene
    Participant

    I’m almost done with a custom implementation of WordPress 3.5.1. It’s a closed community and I have a pretty complex profile page and member directory. I can’t use BuddyPress completely because of specific requirements. For example, some profile attributes are not editable by members, but are required. These fields are populated during member signup, which is also a custom implementation of mine.

    However, eventually I would like to use BuddyPress for most of it’s other community features, such as the activity stream, messaging, forums, etc.

    Any ideas on how I can replace/integrate my profile implementation with BuddyPress? Here are some initial ideas:

    • Override BP profile page with a child theme to use my custom php template to only display the profile not edit it. Is this possible? Then users would use my custom profile form which is in wp-admin.
    • In addition to the above I could hook my profile page to save it’s data in BP’s xprofile tables instead of my custom table.
    • Continue to use my custom implementation but only put the default name field in BP’s xprofile table to “connect” the two profiles together.

    In addition to this, I played around with BP and my implementation and I couldn’t figure out how to filter 2 essential items: links to profile page and avatars.

    1. I have a filter on get_avatar to display the member’s profile headshot, but I couldn’t get BP to display it when I filtered on bp_core_fetch_avatar or bp_core_fetch_avatar_filter.
    2. My member profile page is at /profile/member using a custom specialized page template. Can I filter BP’s profile links to link to this instead of it’s profile page?

    Thanks in advance for any input

Viewing 25 results - 126 through 150 (of 310 total)
Skip to toolbar