Skip to:
Content

BuddyPress.org

Opened 3 years ago

Closed 3 years ago

#8617 closed enhancement (fixed)

Allow disabling avatar revisions in BuddyPress

Reported by: sbrajesh's profile sbrajesh Owned by: imath's profile imath
Milestone: 10.0.0 Priority: highest
Severity: blocker Version:
Component: Core Keywords: commit
Cc: sbrajesh

Description

Hi,
BuddyPress 10.0 introduces the features for avatar revisions and recycling. There is no option to turn this off currently.

There are webmasters who don't need this enabled(I have been requested on our forums about the same). Is it possible to add a filter for the same.

The following patch adds an filter where this feature is left enabled by default but can be disabled for individual types(user, group) or individual objects.

It may be a good idea to add this test to other places. The patch works on the assumption that if there is no prior attachment version(that will be true for a new install), the recycle ui will not be visible. This is a shortcut and there may be a better implementation which takes in account the actual recycle UI(irrespective of avatar history).

Attachments (2)

8617.diff (868 bytes) - added by sbrajesh 3 years ago.
8617.patch (9.4 KB) - added by imath 3 years ago.

Download all attachments as: .zip

Change History (10)

@sbrajesh
3 years ago

#1 @imath
3 years ago

  • Keywords dev-feedback added
  • Milestone changed from Awaiting Review to 10.0.0
  • Priority changed from normal to highest
  • Severity changed from normal to blocker

Hi @sbrajesh

Thanks for your feedback & patch. I believe we need more than just a filter at the place you put it as this feature has been put in place to use the avatar inside the new_avatar activity.

So first thing is to think a bit more about it!

This is a blocker to 10.0.0 release that was scheduled for tomorrow.

#2 @sbrajesh
3 years ago

Hi @imath
Thank you for taking a look promptly.

I did realize that this approach is not suitable if there are previously uploaded avatars. Activity is not the only problem, it causes issue with cropping/setting avatar too.

Looking at the possible solutions and sorry about the last minute reporting.

@imath
3 years ago

#3 @imath
3 years ago

Hi @sbrajesh

Rereading my previous comment, I hope you didn't take this part personally

So first thing is to think a bit more about it!

It was me talking to myself 😅.

Then, I've tried to build 8617.patch according to the discussion we had about it in slack today.

  1. Disabling the avatar history can be done using:
add_filter( 'bp_disable_avatar_history', '__return_true' );

In this case, instead of saving a new revision of the avatar, it's simply deleted. Meaning there's only one avatar available for the user: the latest. new_avatar activities are always using the latest avatar (FYI when avatar history is enabled, it displays the avatar that was in use when the activity was posted).

  1. Disabling richer logging activities can be done using:
add_filter( 'bp_activity_get_types_supporting_generated_content', '__return_empty_array' );

I personally think, we should also make it possible for plugins to disable this feature using a filter even if it's possible to do it using template overrides (which is easier to do when working from a theme). To disable one of the richer logging activity, instead of returning an empty array, you need to use a callback to return the list of allowed activity type names.

To build this I've tried to think about how could evolve activity types feature (I got inspired by the get_post_types_by_support() function). Imho, the $bp->activity->actions global should include a feature property and we should make it possible to register activity types features a bit like WordPress does it for post types. We can probably achieve the WIP function _bp_activity_get_types_by_support() in a future version of BuddyPress.

How do the team feel about this suggestion?

Last edited 3 years ago by imath (previous) (diff)

#4 @sbrajesh
3 years ago

Hi @imath
Thank you.
I am sorry, I did not think there was any issue with your reply. Instead, I wish I could have devoted a bit more time on it and assisted you better.

You have been driving the recent BuddyPress development in a great way and I sincerely appreciate that.

Thank you for the patch. It does work. My suggestion will be to use positive filter( e.g. bp_enable_avatar_history and return true by default). Also, it will make much more sense if you passed the object(user|group) and item id. That will keep it flexible for future.
Just my thoughts :)

#5 @oztaser
3 years ago

Hi @imath,

I've just tested the patch, It looks good to me. I am just not sure about storing old new_avatar activity records when avatar history is disabled. It feels weird seeing the same avatar (the latest one) in all new_avatar activities.

Your suggestion sounds absolutely great to me. I would like to have this feature in BuddyPress.

This ticket was mentioned in Slack in #buddypress by imath. View the logs.


3 years ago

#7 @imath
3 years ago

  • Keywords commit added; has-patch dev-feedback removed

Thanks for your feedbacks to you both, let's have this in and release 10.0.0 asap!

#8 @imath
3 years ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 13215:

Make it possible to disable Avatar history & richer logging activities

Advanced users wishing to:

  1. disable the Avatar history feature, can do so returning true when filtering 'bp_disable_avatar_history',
  2. prevent one or more logging activity types to have a richer output, can return an array of the allowed activity types (or an empty array to completely disable the feature) when filtering 'bp_activity_get_types_supporting_generated_content'.

Props sbrajesh, oztaser

Fixes #8617

Note: See TracTickets for help on using tickets.