Skip to:
Content
Pages
Categories
Search
Top
Bottom

Codex Issue…Error on Avatar Help Page, Please Resolve


  • lookingahead
    Participant

    @lookingahead

    Hi.

    Instructions in the BuddyPress Codex need to be updated. Specifically, regarding options detailed in a screenshot. It was updated 5 months ago, but apparently someone didn’t notice that at the end of the codex (help) page, its instructions and screenshot are no longer applicable. They don’t correspond to the structure of BuddyPress anymore.

    I was looking at this page because my ULTIMATE issue is that I need gravatar images to not be used…at all….and to instead just have local avatar images used in BuddyPress. I’ve gone through basically every avatar plugin in the WordPress plugin repository, and they ‘half-work’ — they fix the issue in bbPress, but not BuddyPress. And I’m using both bbPress and BuddyPress. So you get to my groups and see the “Administrators” display for the groups below the cover photo for the group. Great. BUT, lol…the Gravatar still shows for Administrators there…regardless of if bbPress behaves with plugins that shut off Gravatars and use only local avatars. Turns out that bbPress is quite amenable to using local avatars when told, but BuddyPress sticks up a middle finger to any command to behave as nicely as bbPress does with commands to use local avatars when Gravatars are shut off.

    So I need a solution for BuddyPress that shuts off Gravatars and uses local avatars.

    My users will not be allowed to upload their own avatars. Only Admins will. Ideally, I’d like a default avatar used for every ‘class’ of user…as in, a default Subscriber avatar, a default Author avatar, a default Admin avatar, a default Keymaster avatar….if that is not possible, then I need the option to have a default avatar sitewide, and then I will change the avatar myself (SOMEHOW)…..for each individual user. But regardless of how this is done, I need to be able to SHUT OFF GRAVATARS in BuddyPress. 😀

    Thanks in advance for any and all help.

    In the meantime, the BuddyPress Codex really needs an update on that “Customizing BuddyPress Avatars” page.

    Here’s what I’m talking about:

Viewing 24 replies - 1 through 24 (of 24 total)

  • lookingahead
    Participant

    @lookingahead

    @prashantvatsh if you happen to have any idea how to get BuddyPress to use local avatars and stop trying to use Gravatars…while also allowing for certain classes of users (subscriber, participant, administrator, keymaster, etc.) to have their own default avatar, i’d greatly appreciate it


    lookingahead
    Participant

    @lookingahead

    the direct link to the Codex page if anyone wants to see it:

    https://codex.buddypress.org/themes/guides/customizing-buddypress-avatars/


    Venutius
    Moderator

    @venutius

    Thaks for calling this out, I’ve updated the page with that change. In order to get that option you need to have extended profiles enabled.


    Venutius
    Moderator

    @venutius

    What about – https://wordpress.org/plugins/disable-user-gravatar/ to disable the gravatar?


    lookingahead
    Participant

    @lookingahead

    @venutius glad to have helped — and awesome on updating the page, thanks!

    btw, i’ve shut off user profiles; i do not want my users to be able to update their profiles at all….this is not a social site i’m building, even though buddypress is built with the idea that it resembles something along the lines of facebook…

    my site is going to have groups for the sole purpose of discussion, but not for socializing; i’ve deliberately shut off user profiles so users can’t even see them

    so enabling ‘extended profiles’…wouldn’t that require that i go to the user profile to update an avatar for a user? i’ve disabled that…so even if i were to turn on ‘extended profiles’ how would i be able to upload a user avatar for each user?

    as to that plugin, it works GREAT to shut off gravatar access; it shows the blank BP default image person thing….but even when i pair that plugin with other plugins that allow avatar customization, only bbPress avatars are affected with other plugins; BuddyPress doesn’t work with other plugins that try to get local avatars to show — even if i’ve already shut off the Gravatar display with that fab plugin you linked to (‘disable user gravatar’)


    Venutius
    Moderator

    @venutius

    You’d just set the default avatar for buddypress:

    The default avatar is the one that appear when a user has not yet uploaded his own avatar. If you’re not a fan of the mystery man, here are the constants that you can use to define your own:

    define ( 'BP_AVATAR_DEFAULT', $img_url );
    define ( 'BP_AVATAR_DEFAULT_THUMB', $img_url );

    Change the the constant to include the URL for the location of your new default avatars and add this to your bp-custom.php file.

    define ( 'BP_AVATAR_DEFAULT', 'http://example.com/default-avatar.jpg' );
    define ( 'BP_AVATAR_DEFAULT_THUMB', 'http://example.com/default-avatar-thumb.jpg' );

    To use a default avatar without Gravatar you should also add:

    add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );


    lookingahead
    Participant

    @lookingahead

    @venutius that’s awesome and all, but how would i set different default avatars for different classes of users? as in…participants vs, administrators, etc.?

    and if there is no way to set a different default avatar for each class of users, how would i change the avatar for each user on a case-by-case basis?


    Venutius
    Moderator

    @venutius

    You could use current_user_can( ‘capability’ ) in the file to choose the default avatar to use I would have thought.

    So for example:

    if ( current_user_can( 'edit_posts' ) ) {
       define ( 'BP_AVATAR_DEFAULT', 'http://example.com/default-avatar.jpg' );
       define ( 'BP_AVATAR_DEFAULT_THUMB', 'http://example.com/default-avatar-thumb.jpg' );
    }

    lookingahead
    Participant

    @lookingahead

    @venutius so if i disable user avatar uploads and use current_user_can( ‘capability’ ) in the file as you said….then only me, a keymaster/administrator, can change the user’s avatar? is that what you’re saying?

    where would i go to change it, if the existence of user profiles is disabled?


    Venutius
    Moderator

    @venutius

    I think the same code would work if extended profiles were disabled or not, not tested it though.


    lookingahead
    Participant

    @lookingahead

    @venutius ok, will test that code….but even if that code works to change the default avatar in BuddyPress, how would i change the avatar for each user on a case-by-case basis?

    please note: i will not be able to go to the user’s profile to change their avatar, because profiles are disabled. they do not exist.

    i want to be able to change a user’s avatar, but not allow my users to be able to change their own avatar.


    Venutius
    Moderator

    @venutius

    You could set up a lengthy if statement checking for each users ID and serving a different default, but that sounds like an awful lot of effort.


    lookingahead
    Participant

    @lookingahead

    @venutius agree…..

    thing is, in bbPress there are plugins that easily, and in a lightweight fashion, allow for custom avatars for users

    users can go to their profile in the dashboard and change it

    now, because i also restrict access to the dashboard for users that are not admins, this works. it works because i am then the one, then, that can change the avatars for individual users this way, without having to allow users to change their own avatars, and without enabling the creation of user profiles in BuddyPress

    simple dimple

    but for some godawful reason, even though this means that bbPress avatars can be changed this way via various plugins, BuddyPress doesn’t accept the same change

    i would think that bbPress is not that different, coding-wise, from BuddyPress

    buuuuut hell, i don’t know 😀

    if BuddyPress allowed the customization to happen like bbPress does, of individual avatars from the user dashboard, that would be great

    isn’t there a way to allow BuddyPress to use a bbPress avatar? so i could use the plugin that changes the avatar in bbPress, and then any changes to a bbPress avatar…BuddyPress would show the same avatar???


    lookingahead
    Participant

    @lookingahead

    @venutius if i could juuuust get BuddyPress to use the same avatar that bbPress uses, that would solve basically everything

    that way i could use a plugin that changed the bbPress avatar, and then any change in bbPress’s avatar would show as the avatar for BuddyPress too

    know how to do that?


    Venutius
    Moderator

    @venutius

    One thing to possibly try is to enable extended profiles, disable user profile uploads and see if you can change the avatar yourself from the users profile page. Might not be workable for you but that would be my first approach, as with anythin it’s best if the functionality is already build.

    For what you are asking you’d basically need to write your own plugin that redirected the BP Avatar load to the bbPress Avatar. There’s nothing that does that as far as I’m aware and it normally works the other way round – the BP Avatar is used for both when both are installed.


    lookingahead
    Participant

    @lookingahead

    @venutius thanks!

    you mean the user’s profile page in the dashboard, or the user profile page that is in BuddyPress?


    lookingahead
    Participant

    @lookingahead

    @venutius btw…..i’m referring to the part where you said, “see if you can change the avatar yourself from the users profile page”

    do you mean i should try to change the avatar from the backend, the ‘user profile’ in the dashboard or the user profile page generated in BuddyPress?


    Venutius
    Moderator

    @venutius

    I’ve found a couple of plugins for you to look at:

    BP Local Avatars

    And there is henry’s plugin:

    BuddyPress Identicons


    lookingahead
    Participant

    @lookingahead

    @venutius oh thanks for the suggestions, appreciate the plugin links…but they don’t accomplish what i need to do

    i need specific avatars for classes of users, ones that correspond to the styling and hierarchy of my site

    so identicons being ‘fun’…? sadly i don’t need fun, lol….i need a streamlined business look and fun with random identicons won’t work

    and creating local gravatar avatars for users that ‘don’t have one’ is also random — not corresponding with my site; if i wanted to have default gravatar avatars populate i’d just choose the options that come with WordPress by default — that already is an option

    and gravatar is incredibly cumbersome with its pinging to the servers where the gravatars are stored….it may seem minor to many, but it does burden a site

    plus, gravatars have weak coding that allow the email address of the user to be ‘scraped’ by bots

    so to protect my users from future spam and to keep my site as speedy as possible AND to have my site avatars correspond to the styling of my site i need gravatars to never ever ever be used, and nothing random either


    lookingahead
    Participant

    @lookingahead

    @venutius i think you may have missed my last comment before your plugin suggestions…just want to make sure, are you suggesting i use the front end (user profile page generated in buddypress) to change each user’s avatar….or are you suggesting i use the back end (from the dashboard) to change a user’s avatar after i “disable user profile uploads and see if you can change the avatar yourself from the users profile page”…??


    lookingahead
    Participant

    @lookingahead

    @venutius ohhh i think i found a workaround….

    using that code from the codex that you posted earlier, plus a plugin to restrict user directory access (‘BP Custom Functionalities’) — so users can’t see OTHER user profiles in the directory.

    aaaaand as an added layer of security, i’ve put a 301 redirect on the user directory page itself for anyone who comes across it — they’ll be taken to the home page of the site. even if they’re a keymaster.

    and…..i enabled extended profiles, and the ability for users to upload avatars — keymasters can upload/edit individual profiles, but unfortunately that means that the users themselves can edit their own profiles; i don’t want them to be able to see their own profiles at all….

    so HERE is where i’m at now:
    – i need to find a way for users to NOT even view their OWN profiles

    thoughts?


    lookingahead
    Participant

    @lookingahead

    Ohhh, GOT IT!!

    looks like this code is exactly what is needed….i pasted it into a custom plugin and wa-la…credit goes to the fabulous @prashantvatsh! he replied in the support forum on his plugin (the ‘BP Custom Functionalities’ plugin)…like super quick, with the correct solution to me needing to restrict access to a user’s OWN profile. brilliant!

    here’s that support thread:

    https://wordpress.org/support/topic/restrict-access-to-users-own-profile/

    and here’s the code from prashant that i wound up putting into a custom plugin file and uploading to my site:

    add_action( 'wp', 'bp_own_profile_member_redirect' );
    function bp_own_profile_member_redirect(){
    	if(bp_is_user()){
    	    global $bp;
    	    $current_user_id = (int) trim($bp->loggedin_user->id);
    	    $member_id  = (int) trim($bp->displayed_user->id);
    	    if (!current_user_can('manage_options') && $current_user_id == $member_id)
    	    {
                    //Only admins can view their own profile
    	        wp_redirect(site_url()); //you can set any URL here
    	        exit;
    	    }
    	}
    }

    thanks again for all your help, @venutius — your help was fundamental to me figuring out the next steps (how the BuddyPress avatars exist and how to get those avatars to show what i wanted without messing with bbPress code)…i am truly grateful for all your assistance!


    lookingahead
    Participant

    @lookingahead

    by the way….here’s a summary of what i did:

    – used the code that venutius posted earlier from the BuddyPress codex page (the ‘Customizing BuddyPress Avatars’ codex page) to set a new default BuddyPress avatar

    – turned on the ‘extended profiles’ and also enabled users to be able to upload avatars

    – used prashant singh’s plugin, ‘BP Custom Functionalities’ to restrict listing of all profiles in the user directory — the directory is ‘still there’ but nobody is in it, lol

    – used a 301 redirect (via the ‘Safe Redirect Manager’ plugin) to redirect anyone who goes to the member directory page to the front page of the site…so the page itself is now not even viewable (not even by Keymasters)

    – used prashant singh’s snippet i pasted here to restrict all users from viewing their own profile…except Keymasters, who can view ALL profiles on the site, even their own (so the ‘users cannot see their own profiles’ doesn’t apply to Keymasters but this does apply to everyone else)

    so happy. 😀


    lookingahead
    Participant

    @lookingahead

    so now, anytime i want to edit a specific user’s avatar, i go to the DIRECT link to their profile page…i don’t go to the user directory first and click on it; i type the address directly into the browser

    and i’m on a Keymaster account when i do it….or else i won’t be able to get to that profile link

    wa-la 🙂

Viewing 24 replies - 1 through 24 (of 24 total)
  • You must be logged in to reply to this topic.
Skip to toolbar