Why does WordPress Woocommerce Customer data disappear when I search for it

[ad_1]

I have a function which creates a custom post when A new user is registered. I want to add custom meta tags to this post which are based on the user just created. For some reason, I cannot get any custom user meta tags when I look for them in this function.

I just used $customer = new WC\_Customer($author\_id);
and it displays every single custom meta tag that I’ve been searching for.

However, I might just be dumb, but I don’t know how to access this data.

// Get author ID
$author_id = get_post_field(‘post_author’, $post_ID);
$author_info = get_userdata($author_id);
$customer = new WC_Customer($author_id);

// Add meta tags add_post_meta($post_ID, ‘a_woocommerce_test_1’, $customer, true); add_post_meta($post_ID, ‘a_woocommerce_test_2’, $customer->data, true); add_post_meta($post_ID, ‘a_woocommerce_test_3’, $customer->get_data(), true); add_post_meta($post_ID, ‘a_woocommerce_test_5’, $customer->get_meta_data(), true); add_post_meta($post_ID, ‘a_woocommerce_test_6’, $customer->get_shipping(), true); add_post_meta($post_ID, ‘a_woocommerce_test_7’, $customer->get_billing(), true);

The first test displays all customer information which is great. So I tried to access it, but all the data returns empty ‘ ‘.

As stated I have tried a number of different add\_post\_meta functions with different $meta\_values, but they all return empty ‘ ‘.

Thank you

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer