Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#6612 closed defect (bug) (fixed)

xprofile_avatar_uploaded action hook

Reported by: landwire's profile landwire Owned by: imath's profile imath
Milestone: 2.3.4 Priority: normal
Severity: normal Version: 2.3.0
Component: Media Keywords: has-patch commit
Cc:

Description

Hi there,
I am using the new way to upload attachments/avatars. I really like it!
The xprofile_avatar_uploaded action is fired when a new image is uploaded. I could not find any other information about another hook anywhere, that's why I post this here.

Unfortunately I do not know at that stage if the avatar is actually set, as the user might just decide to abort and not press "Crop Image". Is there an action/filter hook that is fired when the new avatar is actually set (after pressing "Crop Image")? If yes, which one is it, if not, could that be implemented?

Thanks!

Attachments (3)

6612.patch (2.4 KB) - added by imath 9 years ago.
6612.02.patch (3.3 KB) - added by imath 9 years ago.
6612.03.patch (5.1 KB) - added by imath 9 years ago.

Download all attachments as: .zip

Change History (12)

#1 @imath
9 years ago

  • Component changed from Component - Attachments to API - Avatars
  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 2.3.4
  • Type changed from enhancement to defect (bug)
  • Version changed from 2.3.3 to 2.3.0

Hi landwire

Thanks for your feedback :)

I see. This is a bug actually. Today, using the "new way" when a user profile photo has been successfully cropped or set using the camera, the action xprofile_screen_change_avatar is fired, which is wrong.

Because this action's real role is to inform the change avatar screen is displayed.

In previous UI, the action used to inform the avatar has been successfully cropped was xprofile_avatar_uploaded. So i made a confusion in 2.3.0 and put this action too early, once the avatar was successfully uploaded but before it has been cropped.

My mistake. Sorry about it. I suggest the attached patch:

  • Put the action at the right place (even if the name of this hook is confusing we need to keep it for backcompat reasons)
  • Add a new parameter to the action to inform about the way the avatar was set (crop or camera)
  • Stop using the xprofile_screen_change_avatar

@imath
9 years ago

#2 @r-a-y
9 years ago

Looks good, imath!

One thing, should the 'xprofile_avatar_uploaded' hook in bp-xprofile-screens.php pass 'crop' as the parameter?

#3 @imath
9 years ago

Thanks for your feedback @r-a-y. You're absolutely right. I've added it in 02.patch

@imath
9 years ago

#4 @r-a-y
9 years ago

  • Keywords commit added

Good to go in my eyes!

#5 @imath
9 years ago

Thanks r-a-y, i was about to commit it when after some other tests, i've noticed the "changed their avatar" activity was not created when a user is setting his avatar using the wp-admin/extended profile screen.

That's because bp_xprofile_new_avatar_activity() is using bp_displayed_user_id() to get the user id and in the wp-admin/extended profile screen the displayed user id is not set.

So i think we should also add a new parameter to "transport" the user id in the xprofile_avatar_uploaded action.

I've tested 6612.03.patch (Admin/front) and it's fixing the issue, if no objections i will commit it soon.

@imath
9 years ago

#6 @r-a-y
9 years ago

Thumbs up!

#7 @imath
9 years ago

In 10134:

Make sure the xprofile_avatar_uploaded action is fired once the avatar of the user is set.

In 2.3.0, we introduced a new UI to manage avatar. It now uses Ajax to upload and set the avatar. Unfortunately a confusion was made about the xprofile_avatar_uploaded action. It was firing immediately after the avatar was uploaded but before it has been set using the cropping tool.

This commit is:

  • making sure the action is fired at the right time
  • adding new parameters to the action to inform about the User ID and the way the avatar was set ("crop" or "camera")
  • making sure an activity will be generated if the avatar was set within the wp-admin/extended-profile.

Props r-a-y, landwire

See #6612 (branch 2.3)

#8 @imath
9 years ago

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

In 10135:

Make sure the xprofile_avatar_uploaded action is fired once the avatar of the user is set.

In 2.3.0, we introduced a new UI to manage avatar. It now uses Ajax to upload and set the avatar. Unfortunately a confusion was made about the xprofile_avatar_uploaded action. It was firing immediately after the avatar was uploaded but before it has been set using the cropping tool.

This commit is:

  • making sure the action is fired at the right time
  • adding new parameters to the action to inform about the User ID and the way the avatar was set ("crop" or "camera")
  • making sure an activity will be generated if the avatar was set within the wp-admin/extended-profile.

Props r-a-y, landwire

Fixes #6612 (trunk)

#9 @DJPaul
8 years ago

  • Component changed from API - Avatars to Media
Note: See TracTickets for help on using tickets.