Skip to content

Commit

Permalink
Only allow images that were uploaded by this user be used as avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
dkotter committed Nov 12, 2024
1 parent 743c6fe commit ba76619
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions includes/class-simple-local-avatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,11 @@ public function set_avatar_rest( $input, $user ) {
return new \WP_Error( 'invalid_media_id', esc_html__( 'Media ID did not match a valid attachment.', 'simple-local-avatars' ) );
}

// Ensure this attachment is associated with this user.
if ( (int) $attachment->post_author !== (int) $user->ID ) {
return new \WP_Error( 'invalid_media_id', esc_html__( 'This attachment was not uploaded by this user.', 'simple-local-avatars' ) );
}

$this->assign_new_user_avatar( (int) $input['media_id'], $user->ID );
}

Expand Down

0 comments on commit ba76619

Please sign in to comment.