WC_Admin_Profile::get_user_meta()protectedWC 3.1.0

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

{} It's a method of the class: WC_Admin_Profile{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_user_meta( $user_id, $key );
$user_id(int) (required)
User ID of the user being edited
$key(string) (required)
Key for user meta field

Changelog

Since 3.1.0 Introduced.

Code of WC_Admin_Profile::get_user_meta() WC 6.6.1

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;
}