Skip to:
Content

BuddyPress.org

Changeset 11314


Ignore:
Timestamp:
12/20/2016 03:11:18 AM (5 years ago)
Author:
boonebgorges
Message:

Improve actions fired after avatar upload.

  • Introduce the groups_avatar_uploaded action, which paralells the xprofile_avatar_uploaded filter, and runs after either an AJAX or a non-AJAX group avatar upload.
  • Update instances of the xprofile_avatar_uploaded action so that they receive the array of arguments passed to the upload/crop handler.
  • Improve documentation for existing actions.

Props bhargavbhandari90.
Fixes #7371.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-avatars.php

    r11304 r11314  
    12941294             *              about the way the avatar was set (eg: 'crop' or 'camera')
    12951295             *              Move the action at the right place, once the avatar is set
     1296             * @since 2.8.0 Added the `$avatar_data` parameter.
    12961297             *
    1297              * @param string $item_id Inform about the user id the avatar was set for
    1298              * @param string $type    Inform about the way the avatar was set ('camera')
     1298             * @param string $item_id     Inform about the user id the avatar was set for.
     1299             * @param string $type        Inform about the way the avatar was set ('camera').
     1300             * @param array  $avatar_data Array of parameters passed to the avatar handler.
    12991301             */
    13001302            do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'] );
     
    13431345
    13441346        if ( 'user' === $avatar_data['object'] ) {
    1345             /**
    1346              * Fires if the new avatar was successfully cropped.
    1347              *
    1348              * @since 1.1.0 Used to inform the avatar was successfully cropped
    1349              * @since 2.3.4 Add two new parameters to inform about the user id and
    1350              *              about the way the avatar was set (eg: 'crop' or 'camera')
    1351              *              Move the action at the right place, once the avatar is set
    1352              *
    1353              * @param string $item_id Inform about the user id the avatar was set for
    1354              * @param string $type Inform about the way the avatar was set ('crop')
    1355              */
    1356             do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'] );
     1347            /** This action is documented in bp-core/bp-core-avatars.php */
     1348            do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $r );
     1349        } elseif ( 'group' === $avatar_data['object'] ) {
     1350            /** This action is documented in bp-groups/bp-groups-screens.php */
     1351            do_action( 'groups_avatar_uploaded', (int) $avatar_data['item_id'], $atavar_data['type'], $r );
    13571352        }
    13581353
  • trunk/src/bp-groups/bp-groups-screens.php

    r11146 r11314  
    10661066            bp_core_add_message( __( 'There was a problem cropping the group profile photo.', 'buddypress' ), 'error' );
    10671067        } else {
     1068            /**
     1069             * Fires after a group avatar is uploaded.
     1070             *
     1071             * @since 2.8.0
     1072             *
     1073             * @param int    $group_id ID of the group.
     1074             * @param string $type     Avatar type. 'crop' or 'full'.
     1075             * @param array  $args     Array of parameters passed to the avatar handler.
     1076             */
     1077            do_action( 'groups_avatar_uploaded', bp_get_current_group_id(), 'crop', $args );
    10681078            bp_core_add_message( __( 'The new group profile photo was uploaded successfully.', 'buddypress' ) );
    10691079        }
Note: See TracChangeset for help on using the changeset viewer.