Search Results for 'bp_core_fetch_avatar'
-
AuthorSearch Results
-
March 17, 2016 at 10:58 pm #251396
In reply to: BP_AVATAR_DEFAULT_THUMB issue
danbp
ParticipantHi,
default avatar is ‘gravatar’ ‘s mytery man. To use your own avatar, you have to deactivate gravatar in addition to constant. Try this in bp-custom.php
add_filter('bp_core_fetch_avatar_no_grav', '__return_true'); define ( 'BP_AVATAR_DEFAULT_THUMB', 'YOURIMAGEURL' );March 10, 2016 at 1:18 pm #250977In reply to: Avatar images on 3rd party plugin
tkuron
ParticipantI managed to fix the issue.
Apparently BuddyPress does not change the avatar url when get_avatar_data() -function is called. I managed to fix the issue by adding following piece of script to my plugin’s source code:
<?php add_filter("get_avatar_data", function($args, $id_or_email){ $bp_avatar_url = bp_core_fetch_avatar([ "html" => false, "item_id" => $id, "type" => "full", "width" => $args["size"], "height" => $args["size"] ]); $bp_avatar_url = htmlspecialchars_decode($bp_avatar_url); $args["url"] = $bp_avatar_url; return $args; }, 10, 2); ?>March 10, 2016 at 11:31 am #250975In reply to: Avatar images on 3rd party plugin
Henry Wright
ModeratorIf it’s a BuddyPress page then I guess the
bp_core_fetch_avatar()function should display the local avatar if no Grav exists. Are you saying this doesn’t happen?March 10, 2016 at 10:51 am #250971In reply to: Avatar images on 3rd party plugin
Henry Wright
ModeratorYou could disable Gravatar?
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );February 12, 2016 at 12:08 pm #249815In reply to: Problem displaying user avatar
Florent
ParticipantTopic close as result is already formated :
http://hookr.io/functions/bp_core_fetch_avatar/Usage
$string = bp_core_fetch_avatar( $args );
Parameters
$args
( array|string ) optional – { An array of arguments. All arguments are technically optional; some will, if not provided, be auto-detected by bp_core_fetch_avatar(). This auto-detection is described more below, when discussing specific arguments.Returns
string Formatted HTML
element, or raw avatar URL based on $html arg.
November 28, 2015 at 2:24 pm #247239In reply to: Changing avatar images and profile links
Henry Wright
Moderatorbp_core_default_avatar_userwill fire only if you have disabled Gravatar via thebp_core_fetch_avatar_no_gravhook.November 20, 2015 at 6:17 pm #247012In reply to: How to update avatar user meta?
r-a-y
KeymasterWe do not store avatar data in the database.
We do a look up at the files level instead.
If you want to show an avatar based on a custom avatar stored in the database, you’ll need to use the
'bp_core_fetch_avatar'filter to override how BuddyPress shows avatars:
https://buddypress.trac.wordpress.org/browser/tags/2.4.0/src/bp-core/bp-core-avatars.php?marks=531-546,660-664#L531If you just want to display a user avatar, use the
bp_core_fetch_avatar()function:echo bp_core_fetch_avatar( array( 'item_id' => USER_ID_TO_GRAB_AVATAR_FOR ) );October 31, 2015 at 12:56 pm #246176In reply to: [Resolved] Change the default avatar
silversurfer.wf
ParticipantOK, for some reason that did not cut and paste correctly. The add_filter line looks like this.
add_filter( 'bp_core_fetch_avatar_no_grav','__return_true' );
October 31, 2015 at 12:54 pm #246175In reply to: [Resolved] Change the default avatar
silversurfer.wf
ParticipantThe following code…
<?php
// Use this file to customize Buddy Press
// This section changes the default avatar to the picture of a box
// the picture is uploaded into WordPress
add_filter( 'bp_core_fetch_avatar_no_grav','__return_true' );
define ( ‘BP_AVATAR_DEFAULT’, ‘http://www.truesouthernmen.com/wp-content/uploads/2015/10/0307152159-02-300×225.jpg’ );
define ( ‘BP_AVATAR_DEFAULT_THUMB’, ‘http://www.truesouthernmen.com/wp-content/uploads/2015/10/0307152159-02-300×225.jpg’ );?>
Returns this error when loading the page…..
Fatal error: Can’t use function return value in write context in /home/cody7670/public_html/wp-content/plugins/bp-custom.php on line 8
October 31, 2015 at 11:00 am #246171In reply to: [Resolved] Change the default avatar
Brajesh Singh
ParticipantFor that purpose, please put the following line too in your bp-custom.php
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );That forces BuddyPress to avoid using gravatar and use local avatars for default(when no avatar is uploaded).
Hope that helps
October 30, 2015 at 10:09 am #246145danbp
ParticipantBuddyPress use Gravatar by default, like WordPress.
If your user uploaded custom avatars, you may usebp_core_fetch_avatarin place of wp’sget_avatarhttp://oik-plugins.eu/buddypress-a2z/oik_api/bp_core_fetch_avatar/
More about avatars here and search for “avatar”
http://hookr.io/plugins/buddypress/#index=aOctober 18, 2015 at 12:30 am #245627LaurieDugdale
ParticipantFound the code below on these forums works perfectly.
function my_cache_avatar_url() { update_user_meta( bp_displayed_user_id(), 'modemloopers_awesome_avatar_url', bp_core_fetch_avatar( 'html=false&item_id=' . bp_displayed_user_id() ) ); } add_action( 'xprofile_screen_change_avatar', 'my_cache_avatar_url' );I’ve tried to make it work for an xprofile field by doing the code below with no such luck. Any ideas?
function my_cache_xprofile_website() { update_user_meta( bp_displayed_user_id(), 'modemloopers_awesome_website_url', bp_profile_field_data('field=Website&item_id=' . bp_displayed_user_id() ) ); } add_action( 'xprofile_updated_profile ', 'my_cache_xprofile_website' );September 18, 2015 at 8:49 pm #244571In reply to: [Resolved] period or special characters in username
alpha2
ParticipantYes it is. But rather than using a plugin (for this project i am nearly at 53 active plugins…too much) maybe its better to use a function.
i use this thread to ask you another question, some users (registered before i applied this plugin) named their account with a period: john.doe . Actually it’s not a big deal because buddypress (or wordpress natively) transform this dot into hyphen in each link.On one specific page template, I have special function i created with the help of a dev to display all users by a custom taxonomy (ranks)
Only mater is that every hyperlink that link to account like john.doe are display like this http://www.website.com/members/john.doe and not http://www.website.com/members/john-doe
I search into the code and found this:
<div><?php $user = get_user_by('id', $gold ); ?><a href="<?php echo site_url();?>/members/<?php echo $user->user_login;?>/buddyblog/"><?php echo bp_core_fetch_avatar( array( 'item_id' => $gold, 'type' => 'full' ) ); ?></a><a href="<?php echo site_url();?>/members/<?php echo $user->user_login;?>/buddyblog/"><?php echo $user->user_login; ?></a>Performances: <?php echo count_user_posts( $gold ); ?></div>I must change how is display the username.
Thank you for your time and your help!
September 5, 2015 at 3:13 pm #244091In reply to: [Resolved] Gravatar won’t update?
shanebp
ModeratorThis is not a gravatar:
http://chocobento.x10.mx/wp/wp-content/uploads/avatars/1/63d3ab039b099fd772971c5498789561-bpfull.jpg

You can disable gravatars by adding this to your theme/functions.php
add_filter('bp_core_fetch_avatar_no_grav', '__return_true');August 24, 2015 at 3:49 pm #243539In reply to: avatar url insert database
fatihaslann
ParticipantI place this code in function.PHP
function my_cache_avatar_url() { update_user_meta( bp_displayed_user_id(), 'modemloopers_awesome_avatar_url', bp_core_fetch_avatar( 'html=false&item_id=' . bp_displayed_user_id() ) ); } add_action( 'xprofile_screen_change_avatar', 'my_cache_avatar_url' );But my web site show white screen
August 24, 2015 at 10:19 am #243527In reply to: avatar url insert database
fatihaslann
ParticipantWhere should I place on which page this code?
function my_cache_avatar_url() { update_user_meta( bp_displayed_user_id(), 'modemloopers_awesome_avatar_url', bp_core_fetch_avatar( 'html=false&item_id=' . bp_displayed_user_id() ) ); } add_action( 'xprofile_screen_change_avatar', 'my_cache_avatar_url' );July 27, 2015 at 4:19 pm #242474In reply to: Profile avatar directory location
Henry Wright
ModeratorYou can disable Gravatar like this:
function no_grav() { return true; } add_filter( 'bp_core_fetch_avatar_no_grav', 'no_grav' );July 24, 2015 at 12:08 am #242191In reply to: BP_Group_Member_Query type alphabetical
Garrett Hyder
ParticipantHi @shanebp,
Sorry for the confusion, I’ve created a bp_group_list_managers that’s a merge of bp_group_list_admins and bp_group_list_mods to provide a single consolidated listing.
function bp_group_list_managers($group=false) { global $groups_template; if(empty($group)) { $group =& $groups_template->group; } // fetch group admins if 'populate_extras' flag is false if (empty($group->args['populate_extras']) || true) { $query = new BP_Group_Member_Query(array( 'group_id' => $group->id, 'group_role' => 'admin', 'type' => 'alphabetical', )); if (!empty($query->results)) { $group->admins = $query->results; } } // fetch group mods if 'populate_extras' flag is false if (empty($group->args['populate_extras']) || true) { $query = new BP_Group_Member_Query(array( 'group_id' => $group->id, 'group_role' => 'mod', 'type' => 'alphabetical', )); if (!empty($query->results)) { $group->mods = $query->results; } } $admins = (array)$group->admins; $mods = (array)$group->mods; usort($admins, 'bp_group_member_sort'); usort($mods, 'bp_group_member_sort'); $group->managers = array_merge($admins, $mods); if (!empty($group->managers)) { ?> <ul id="group-managers"> <?php foreach((array)$group->managers as $manager) { ?> <li> <a href="<?php echo bp_core_get_user_domain($manager->user_id, $manager->user_nicename, $manager->user_login); ?>"><?php echo bp_core_fetch_avatar(array('item_id' => $manager->user_id, 'email' => $manager->user_email, 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_core_get_user_displayname($manager->user_id)))) ?></a> </li> <?php } ?> </ul> <?php } else { ?> <span class="activity"><?php _e( 'No Managers', 'buddypress' ) ?></span> <?php } }As you can see I set the type here to alphabetical and was first confused why it did nothing then I realized the BP_Group_Member_Query’s were never even called as I guess populate_extras was set so not empty. This meant that the $group->admins and $group->mods came from the global $group_template->group which wasn’t ordered. I’m curious how to make that global $group_template->group admin/mod lists could be alphabetically ordered by default.
For now I just amended my method to simply force the BP_Group_Member_Query’s to be used instead which has allowed for the alphabetical ordering.
Hope that clears things up.
Thanks
June 23, 2015 at 1:31 am #240990In reply to: xprofile_avatar_uploaded and bp_core_fetch_avatar
shanebp
ModeratorThat’s a tricky one. And I don’t have a solution.
It’s probably a timing issue. The hook fires before the dir is updated.
Or maybe bp_core_fetch_avatar is cached.Which version of BP are you using?
The issue may be related to the new approach to avatar uploads using the BP_Attachments class.June 4, 2015 at 6:22 pm #240216In reply to: display recently registered users
shanebp
ModeratorThe sql call isn’t returning the user ID.
Change the sql to:
$usernames = $wpdb->get_results("SELECT ID, user_nicename FROM $wpdb->users ORDER BY ID DESC LIMIT 5");Then make this change:
$recentusers .= '<li>' . bp_core_fetch_avatar( array( 'item_id' => $username->ID, 'type' => 'full') ) . '<a href="' . bp_core_get_user_domain($username->ID) .'">' . $username->user_nicename . '</a></li>';April 27, 2015 at 6:15 pm #238471In reply to: Remove Everything Gravatar
@mcuk
ParticipantThanks for the explanation @danbp. Ahhhh the Mystery Man ha.
WP is using get_avatar and BP substitute it with his own code for internal purpose.
So if i understand you, WP calls for the user’s Gravatar regardless via
get_avatarand Buddypress then just takes it from WP to make it appear on the user profile? Therefore the codeadd_filter('bp_core_fetch_avatar_no_grav', '__return_true');only stops the second part of the process where Buddypress requests the user’s Gravatar from WP. That right?Deactivating Gravatar will also deprive the people who use the service to get their usual picture on your site. It’s not an innocent decision.
Yeah I agree. The reasons I have now for wanting to prevent access to Gravatar is for data/privacy/3rd party website reasons and also slowdown (if the user numbers did reach certain levels). I don’t want to ‘force’ them to upload a profile pic because I want them to give as little or as much to their profile as they feel like (which is why I wouldn’t use the Buddydev force profile pic plugin either).
April 27, 2015 at 2:12 pm #238444In reply to: Remove Everything Gravatar
@mcuk
ParticipantThanks @henrywright! I’ll stick with
add_filter('bp_core_fetch_avatar_no_grav', '__return_true');then if it’s all I need to stop the Buddypress calls. What is it that WordPress calls for? Are you referring to the default ‘white figure on grey background’? Or does WordPress also check for a Gravatar in similar way to Buddypress. (I don’t currently use Gravatar).Hi @djsteveb , I came across some of those posts you listed which is actually what got me thinking about it in the first place :). I’m trying to be as transparent as possible on user privacy/data on the site I’m creating. Searched the forums a little further and some of the threads are v old so thought I’d check if the stuff there was still applicable or had been deprecated.
Hi @danbp, thanks for the plugin suggestions. I’ve come across a few Buddydev plugins and will probably use their ‘bp-activity-comment-notifier’ plugin since they aren’t part of Buddypress default currently. Trying to keep plugins to a minimum early on.
With regards to the ‘bp-avatar-suggestions’ plugin (which you appear to have inspired), does that override any WordPress calls Henry mentioned above since you are using your own locally stored images? (similar I guess to the new user Twitter eggs)?April 24, 2015 at 9:21 pm #238324In reply to: Avatar does not show outside BuddyPress
danbp
ParticipantPrevious snippet changed all avatars (user, blogs and groups) which is not what you want. Here’s a snippet which works almost correctly, but not to 100%. Give it a try anyway.
It changes the user avatar depending of an xprofile value.
(add to bp-custom.php)
function bpfr_my_new_avatar_url() { global $bp; if( bp_is_user() && ! bp_get_member_user_id() ) { $user_id = bp_displayed_user_id(); } else { $user_id = bp_get_member_user_id(); } if ( is_page( 'activity' ) ) { $user_id = bp_get_activity_user_id(); } $ranking = xprofile_get_field_data ('ranking', $user_id ); if ($ranking == "Top 25") { $url = get_stylesheet_directory_uri() .'/custom_img/25.png'; } if ($ranking == "Top 24") { $url = get_stylesheet_directory_uri() .'/custom_img/24.png'; } return $url; } add_filter( 'bp_core_default_avatar_user', 'bpfr_my_new_avatar_url' );Create a profile field called “ranking” with 2 options (top 24 & top 25).
Create a folder in your child-theme called “custom_img” and add 2 pictures: 24.png & 25.png (250×250)
If everybody must those avatars, disallow avatar upload in BP settings.
Site default avatar stays as Mystery Man (wp default setting).You have also to get rid of Gravatar, so you must add this to bp-custom.php
add_filter('bp_core_fetch_avatar_no_grav', '__return_true');The thing who doesn’t work is related to
X & Y are now friends. Both willhave the same avatar.Can probably by better improved.
April 23, 2015 at 11:56 pm #238296In reply to: Avatar does not show outside BuddyPress
paixaofileto
ParticipantTried a new code using bp_profile_field_data:
wpse_49216_my_new_avatar_url function () { $ current_user = wp_get_current_user (); $ current_user_id = $ current_user-> ID; global $ bp; $ var = bp_profile_field_data (array ('user_id' => $ current_user_id, 'field' => 'ranking')); if ($ var == "Cranking") { return 'http://hsseek2.esy.es/wp-content/uploads/2015/04/lendario.png'; } if ($ var == "Dranking") { return 'http://hsseek2.esy.es/wp-content/uploads/2015/04/25.png'; } } add_filter ('bp_core_fetch_avatar_url', 'wpse_49216_my_new_avatar_url'); function wpse_49216_filter_bp_avatar ($ html) { return preg_replace ('/src=".+?"/', 'src =' 'wpse_49216_my_new_avatar_url ()..' "', $ html); } add_filter ('bp_core_fetch_avatar', 'wpse_49216_filter_bp_avatar');It now appears the name of the field on the homepage, but I need to treat the value returned by bp_profile_field_data it looks like is:
username: teste
password: 1234What value the bp_profile_field_data returns? How can I treat it?
April 23, 2015 at 8:09 pm #238287In reply to: Avatar does not show outside BuddyPress
paixaofileto
Participantthe code I am using is:
wpse_49216_my_new_avatar_url function () { global $ bp; $ranking = xprofile_get_field_data ('ranking', bp_get_member_user_id ()); if ($ranking == "Top 25") { return 'http://hsseek2.esy.es/wp-content/uploads/2015/04/25.png'; } if ($ gender == "Top 24") { return 'http://hsseek2.esy.es/wp-content/uploads/2015/04/24.png'; } } add_filter ('bp_core_fetch_avatar_url', 'wpse_49216_my_new_avatar_url'); function wpse_49216_filter_bp_avatar ($ html) { return preg_replace ('/src=".+?"/', 'src =' 'wpse_49216_my_new_avatar_url ()..' "', $ html); } add_filter ('bp_core_fetch_avatar', 'wpse_49216_filter_bp_avatar');in function.php
-
AuthorSearch Results