Search Results for 'bp_core_fetch_avatar'
-
Search Results
-
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
ConorHi 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
ConorI 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
Topic: avatar width doesn't apply
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; } }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).
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.
Topic: Check for Avatar
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.’;
}
}
?>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?
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?
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.
- 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.
- 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