Skip to:
Content
Pages
Categories
Search
Top
Bottom

Profile avatar directory location


  • dgcov
    Participant

    @dgcov

    Hi, my users have profile pictures which are located in wp-content/plugins/chron_reg/images.

    These are referred to by filename (without the path) in the user_meta table meta-key name ‘avatar’.

    Is there a way of passing this path to Buddypress as the default avatar?

    Many thanks,

    Dave

    WP version recently updated to 4.2.3
    BP version updated to 2.3.2.1
    site: haroldwoodrc.co.uk (forgive the garish theme).

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

  • Henry Wright
    Moderator

    @henrywright

    Cool running club! I was looking to join a club near me but Harold Wood is about a 30 minute drive away.

    Regarding your question:

    Is there a way of passing this path to Buddypress as the default avatar?

    You can filter the default avatar URL using the bp_core_default_avatar_user hook.

    Hope this helps!


    dgcov
    Participant

    @dgcov

    Hi Henry!

    30 minutes too long for you? My cousin started it up last year and it’s apparently doing hugely well, if not in the running times, certainly socially. Very high proportion of female members which is undoubtedly a major proponent of a good social scene. The running is enthusiastic rather than olympian.

    With regards to the avatar issue, that will change the default avatar, no?

    All users have uploaded their custom avatars and these are in the directory mentioned in the OP.


    dgcov
    Participant

    @dgcov

    Ah, ok, I see it!

    The add_filter( 'bp_core_default_avatar_user', 'feed_user_avatar' );
    function feed_user_avatar(){
        $user_id=get_current_user_id();
        if(!$user_id){
          return;
        }
        $userMetaData=get_user_meta($user_id);
      return 'wp-content/plugins/chron_reg/images/'.$userMetaData['avatar'][0];
    }

    Cheers!


    Henry Wright
    Moderator

    @henrywright

    That would be 30 minutes on a good day. At 6:30pm I’d hit the worst traffic imaginable (I’d be coming from the Isle of Dogs). But it’s great to hear it’s a success!

    My apologies, yes that’ll change the default avatar. I just re read your whole post and realise that may not be what you want.


    dgcov
    Participant

    @dgcov

    Yes, I’d probably want to override the gravatar entirely and just replace it with the local avatar.


    Henry Wright
    Moderator

    @henrywright

    You can disable Gravatar like this:

    function no_grav() {
        return true;
    }
    add_filter( 'bp_core_fetch_avatar_no_grav', 'no_grav' );

    dgcov
    Participant

    @dgcov

    Ok, so if my function returns: 'wp-content/plugins/chron_reg/images/'.$userMetaData['avatar'][0];, that will disable the gravatar anyway?

    return 'wp-content/plugins/chron_reg/images/'.$userMetaData['avatar'][0]; will obviously return ‘true’?

    So will that disable the gravatar even if it exists?


    Henry Wright
    Moderator

    @henrywright

    I haven’t tested or looked at the source but I suspect you will need to use my no_grav() function as well. You could run a quick test to be sure?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Profile avatar directory location’ is closed to new replies.
Skip to toolbar