WC_Admin_Profile::get_user_meta( int $user_id, string $key )

Get user meta for a given key, with fallbacks to core user info for pre-existing fields.


Description Description


Parameters Parameters

$user_id

(Required) User ID of the user being edited

$key

(Required) Key for user meta field


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/admin/class-wc-admin-profile.php

		protected function get_user_meta( $user_id, $key ) {
			$value           = get_user_meta( $user_id, $key, true );
			$existing_fields = array( 'billing_first_name', 'billing_last_name' );
			if ( ! $value && in_array( $key, $existing_fields ) ) {
				$value = get_user_meta( $user_id, str_replace( 'billing_', '', $key ), true );
			} elseif ( ! $value && ( 'billing_email' === $key ) ) {
				$user  = get_userdata( $user_id );
				$value = $user->user_email;
			}

			return $value;
		}

Top ↑

Changelog Changelog

Changelog
Version Description
3.1.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.