I'm using WooCommerce and need to get my users billing name, billing address, billing phone, billing email, etc from wp_usermeta in a good format like this:
name,address,phone,email
fake name, 123 stackexchange rd,111-111-1111,[email protected]
Anyone know how to do something like this? I need to do it for alot of users (10k+) in one go if possible. I tried using some php code but it didnt work. Any help appreciated
I'm using WooCommerce and need to get my users billing name, billing address, billing phone, billing email, etc from wp_usermeta in a good format like this:
name,address,phone,email
fake name, 123 stackexchange rd,111-111-1111,[email protected]
Anyone know how to do something like this? I need to do it for alot of users (10k+) in one go if possible. I tried using some php code but it didnt work. Any help appreciated
Share Improve this question asked Nov 4, 2015 at 20:52 Vitor GVitor G 1 1- 1 Please tell what you tried. – HU is Sebastian Commented Nov 4, 2015 at 21:39
1 Answer
Reset to default 1You can use meta_query to specify what conditions you want to meet with that query you are performing. i.e.:
// grab some record from DB with a specific meta query
$args = array(
'post_type' => array( 'woo_commerce_something' ),
'orderby' => 'rand',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'meta_something_woo_commerce_email',
'value' => 'email@[email protected]'
)
)
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
// do something
endwhile;
endif;
wp_reset_postdata();