Commit 05d3dc601c for woocommerce
commit 05d3dc601c6770b83183aaef5a52aeacf5f83b4c
Author: George Stephanis <daljo628@gmail.com>
Date: Mon Jan 19 03:42:41 2026 -0500
Ensure that the $single parameter of `get_site_user_meta` is respecte… (#61926)
* Ensure that the $single parameter of `get_site_user_meta` is respected instead of ignored.
I was reading the code and noticed that $single was an argument, but never actually used -- the value being hardcoded to `true` instead.
I've not done an in-depth investigation to usage on this -- I just toggled the default value to match what had been enacted previously so as to not break prior integrations.
* Add changefile(s) from automation for the following project(s): woocommerce
---------
Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/61926-patch-1 b/plugins/woocommerce/changelog/61926-patch-1
new file mode 100644
index 0000000000..10807e714e
--- /dev/null
+++ b/plugins/woocommerce/changelog/61926-patch-1
@@ -0,0 +1,4 @@
+Significance: minor
+Type: fix
+
+Fix get_site_user_meta method to respect arguments passed to it.
\ No newline at end of file
diff --git a/plugins/woocommerce/src/Internal/Utilities/Users.php b/plugins/woocommerce/src/Internal/Utilities/Users.php
index 1e5c3998d0..7b35f37a9b 100644
--- a/plugins/woocommerce/src/Internal/Utilities/Users.php
+++ b/plugins/woocommerce/src/Internal/Utilities/Users.php
@@ -160,16 +160,16 @@ class Users {
* @param int $user_id User ID.
* @param string $key Optional. The meta key to retrieve. By default, returns data for all keys.
* @param bool $single Optional. Whether to return a single value. This parameter has no effect if `$key` is not
- * specified. Default false.
+ * specified. Default true (WordPress's `get_user_meta()` defaults this to false).
*
* @return mixed An array of values if `$single` is false. The value of meta data field if `$single` is true.
* False for an invalid `$user_id` (non-numeric, zero, or negative value). An empty string if a valid
* but non-existing user ID is passed.
*/
- public static function get_site_user_meta( int $user_id, string $key = '', bool $single = false ) {
+ public static function get_site_user_meta( int $user_id, string $key = '', bool $single = true ) {
global $wpdb;
$site_specific_key = $key . '_' . rtrim( $wpdb->get_blog_prefix( get_current_blog_id() ), '_' );
- return get_user_meta( $user_id, $site_specific_key, true );
+ return get_user_meta( $user_id, $site_specific_key, $single );
}
/**