Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/148 | Expose hooks for "avatar updated" and "avatar deleted" #149

Merged
merged 4 commits into from
Sep 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions includes/class-simple-local-avatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,15 @@ public function assign_new_user_avatar( $url_or_media_id, $user_id ) {
$meta_value['blog_id'] = get_current_blog_id();

update_user_meta( $user_id, $this->user_key, $meta_value ); // save user information (overwriting old).

/**
* Enable themes and other plugins to react to changes to a user's avatar.
*
* @since 2.6.0
*
* @param int $user_id Id of the user who's avatar was updated
*/
do_action( 'simple_local_avatar_updated' , $user_id );
dkotter marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -1055,6 +1064,15 @@ public function action_remove_simple_local_avatar() {

$this->avatar_delete( $user_id ); // delete old images if successful

/**
* Enable themes and other plugins to react to avatar deletions.
*
* @since 2.6.0
*
* @param int $user_id Id of the user who's avatar was deleted.
*/
do_action( 'simple_local_avatar_deleted', $user_id );

if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
echo wp_kses_post( get_simple_local_avatar( $user_id ) );
}
Expand Down