From 6fcf6babc356bf5af3ee00907fac50f5811ab38d Mon Sep 17 00:00:00 2001 From: David Stone Date: Thu, 30 Jan 2025 00:37:39 -0700 Subject: [PATCH] Fix deprecation notice when validating a WP_User object. --- inc/helpers/validation-rules/class-unique.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/inc/helpers/validation-rules/class-unique.php b/inc/helpers/validation-rules/class-unique.php index d2cd8c4..e87f677 100644 --- a/inc/helpers/validation-rules/class-unique.php +++ b/inc/helpers/validation-rules/class-unique.php @@ -86,8 +86,11 @@ class Unique extends Rule { return true; } // end if; - - $id = method_exists($existing, 'get_id') ? $existing->get_id() : $existing->id; + if ( $existing instanceof \WP_User) { + $id = $existing->ID; + } else { + $id = method_exists( $existing, 'get_id' ) ? $existing->get_id() : $existing->id; + } return absint($id) === absint($self_id);