Search Results for 'bp_core_fetch_avatar'
-
AuthorSearch Results
-
June 23, 2015 at 1:31 am #240990
In reply to: xprofile_avatar_uploaded and bp_core_fetch_avatar
shanebpModeratorThat’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
shanebpModeratorThe 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
@mcukParticipantThanks 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_avatar
and 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
@mcukParticipantThanks @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
danbpParticipantPrevious 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
paixaofiletoParticipantTried 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
paixaofiletoParticipantthe 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
April 23, 2015 at 4:59 pm #238282In reply to: Avatar does not show outside BuddyPress
paixaofiletoParticipantThe avatars only works when I’m in BuddyPress pages.
I want to make it work around the site by adding the following code passing the user ID I found searching for:<? php $ Userid = bp_loggedin_user_id (); echo bp_core_fetch_avatar (array ('item_id' => $ id user)); ?>
But in which .phpeu add file this code?
April 23, 2015 at 11:57 am #238266In reply to: Avatar does not show outside BuddyPress
paixaofiletoParticipantgave the following error:
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘: 1)’ at line 1]
SELECT id, user_id, field_id, value, last_updated FROM wp_bp_xprofile_data WHERE field_id = 2 AND user_id IN (displayed: 1)Read on the internet that I must pass the id as parameter for bp_core_fetch_avatar:
<?php $userid = bp_loggedin_user_id(); echo bp_core_fetch_avatar( array( ‘item_id’ => $userid) ); ?>
But do not know where I have to put this code or how to implement in my code. Can you help me?
April 23, 2015 at 11:39 am #238263In reply to: Avatar does not show outside BuddyPress
danbpParticipantTry this:
function wpse_49216_my_new_avatar_url() { global $bp; if( bp_is_user() && !bp_get_member_user_id() ) { $user_id = 'displayed: '. bp_displayed_user_id(); } else { $user_id = 'get_member_user: '. bp_get_member_user_id(); } $gender = xprofile_get_field_data ( 'ranking', $user_id ); if ($gender == "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');
April 13, 2015 at 6:37 pm #237835danbpParticipantProbably not, but see here if it helps
http://oik-plugins.eu/buddypress-a2z/oik_api/bp_core_fetch_avatar/March 27, 2015 at 10:57 pm #236796In reply to: User avatar in side widget
shanebpModeratorbp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'full' ) );
‘full’ will be the large size at whatever that is set to – usually 150px.
March 26, 2015 at 1:37 am #236638In reply to: User avatar in side widget
shanebpModerator<?php $user_id = get_current_user_id(); ?> <a href="<?php echo bp_core_get_user_domain( $user_id ); ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_id ) ); ?></a>
March 13, 2015 at 11:04 pm #235984In reply to: Using BuddyPress profile image
shanebpModeratorYour request is more properly asked of the plugin creator.
You could try this:
Open birds-author-box\public\frontend.php and replace this:if (get_the_author_meta('image', get_query_var('author'))) { $content.= '<img class="birds_box_avatar" src="' . get_the_author_meta('image', get_query_var('author')) . '">'; } else { $blank = plugin_dir_url(__FILE__) . 'img/blank.png'; $content.= '<img class="birds_box_avatar" src="' . $blank . '">'; }
with this:
$avatar_args = array( 'item_id' => get_the_author_meta('ID', get_query_var('author')), 'type' => 'thumb', 'html' => false ); $content.= '<img class="birds_box_avatar" src="' . bp_core_fetch_avatar( $avatar_args ) . '">';
March 4, 2015 at 10:05 pm #235469In reply to: If a number have same number get_avatar
tipsyParticipantthank you @danbp I will start right away!
Here is were I am now (not working):
<?php if ($entry[1] == xprofile_get_field_data(2, $user_id)); { echo bp_core_fetch_avatar($user_id); } ?>
March 4, 2015 at 9:21 pm #235466In reply to: If a number have same number get_avatar
danbpParticipantOctober 1, 2014 at 6:58 am #203190In reply to: [Resolved] Remove GRAVATAR completely
danbpParticipantthe link given by @drakedoc was started over 4 years. Many solutions are given in this thread, and the last one was published a year ago.
That solution works for 1.9 and above !
/* Skip the Gravatar check when using a default BP avatar */ add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );
By the way you have also to modify the global WP setting of avatars to “mystery man” or “nothing”.
Another solution to avoid gravatars slowing down a big site (at least > 500 members), is to use a specific cache plugin like Nix Gravatar Cache. Complete list here.
September 17, 2014 at 11:53 am #197233In reply to: Profile picture to use wordpress avatar
Henry WrightModeratorHi @tightflks
You can use
get_avatar()
instead of the BuddyPress functionbp_core_fetch_avatar()
. See: https://codex.wordpress.org/Function_Reference/get_avatarAugust 21, 2014 at 2:09 pm #187695In reply to: Please help – Use WordPress Avatars not BuddyPress?
Henry WrightModeratorThere might actually be more things you’d need to do. For example, the
bp_get_message_thread_avatar()
function usesbp_core_fetch_avatar()
so you would need to filter that usingbp_get_message_thread_avatar
etc.Unless someone else knows of an easier way, it seems as though it’ll be a big task of going through everything. You’d also need to be comfortable with PHP.
Alternatively, you could try disabling avatars by adding this to your bp-custom.php file
define( 'BP_SHOW_AVATARS', false );
Note: I’ve not tested that, I’m just going on what I see at the beginning of the
bp_core_fetch_avatar()
function. i.e:// If avatars are disabled for the root site, obey that request and bail if ( ! buddypress()->avatar->show_avatars ) return;
August 21, 2014 at 1:53 pm #187692In reply to: Please help – Use WordPress Avatars not BuddyPress?
Martin WallerParticipantOkay, so searching that GitHub repo there is only one file under the bp-themes/bp-legacy/buddypress folders which mentions
bp_core_fetch_avatar()
(but lots within the core BuddyPress code. So I just need to replace the reference in that one file and add it to by child theme under a BuddyPress folder and it should work?August 21, 2014 at 11:19 am #187685In reply to: Please help – Use WordPress Avatars not BuddyPress?
Martin WallerParticipantThanks @henrywright…
I’m not entirely sure that my front-end template actually references bp_core_fetch_avatar() as it is not a BuddyPress theme but rather a regular WordPress theme (Responsive Pro).
Martin
August 21, 2014 at 11:17 am #187684In reply to: Please help – Use WordPress Avatars not BuddyPress?
Henry WrightModeratorActually scratch that last post – it’s now displaying the avatars as the WordPress avatars in the back-end but not the front end
In that case, I think we’ve just crossed that bridge hehe. i.e the next step will be to replace all instances of
bp_core_fetch_avatar()
in your front-end templates withget_avatar()
August 21, 2014 at 10:53 am #187679In reply to: Please help – Use WordPress Avatars not BuddyPress?
Henry WrightModeratorHumm.. not helpful then. In that case we might have to try doing it manually. Perhaps try disabling the filter which replaces the WP avatars with BP avatars. For example, add this to your theme’s functions.php file:
remove_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 );
I think you can disable the Gravatar fallback as well with this:
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );
If that doesn’t work, you may need to replace all occurrences of
bp_core_fetch_avatar()
withget_avatar()
in your templates. But cross that bridge when you come to it.Ref: https://codex.wordpress.org/Function_Reference/get_avatar
August 18, 2014 at 6:52 pm #187149In reply to: Get E-mail addresses of users without Photos?
adamt19ParticipantThis worked for me
function no_photos() { global $wpdb; $nophotoids = array(); $ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->prefix}users" ); foreach( $ids as $id ) { $avatar_check = false; if ( preg_match('/mystery-man.jpg/', bp_core_fetch_avatar( array( 'item_id' => $id, 'no_grav' => true, 'html'=> false ) ) ) ) $avatar_check = true; if( ! $avatar_check ) { $nophotoids[] = $id; } } $nophotoids = implode(",", $nophotoids); echo 'no photo ids: ' . $nophotoids; }
July 2, 2014 at 11:49 pm #184752In reply to: Get E-mail addresses of users without Photos?
shanebpModeratoruntested:
function no_photos() { global $wpdb; $emails = array(); $ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->prefix}users" ); foreach( $ids as $id ) { $avatar_check = false; if ( bp_core_fetch_avatar( array( 'item_id' => $id, 'no_grav' => true, 'html'=> false ) ) != bp_core_avatar_default() ) $avatar_check = true; if( ! $avatar_check ) { $email = $wpdb->get_var( "SELECT user_email FROM {$wpdb->prefix}users WHERE ID = $id" ); $emails[] = $email; } } $emails = implode(",", $emails); return $emails; }
-
AuthorSearch Results