Automattic\WooCommerce\Internal\Admin
WCAdminUser::get_user_data_field()
Helper to retrieve user data fields.
Migrates old key prefixes as well.
Method of the class: WCAdminUser{}
No Hooks.
Return
Mixed
. The user field value.
Usage
$result = WCAdminUser::get_user_data_field( $user_id, $field );
- $user_id(int) (required)
- User ID.
- $field(string) (required)
- Field name.
WCAdminUser::get_user_data_field() WCAdminUser::get user data field code WC 9.3.3
public static function get_user_data_field( $user_id, $field ) { $meta_value = get_user_meta( $user_id, 'woocommerce_admin_' . $field, true ); // Migrate old meta values (prefix changed from `wc_admin_` to `woocommerce_admin_`). if ( '' === $meta_value ) { $old_meta_value = get_user_meta( $user_id, 'wc_admin_' . $field, true ); if ( '' !== $old_meta_value ) { self::update_user_data_field( $user_id, $field, $old_meta_value ); delete_user_meta( $user_id, 'wc_admin_' . $field ); $meta_value = $old_meta_value; } } return $meta_value; }