最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

users - Get usermeta info from sql query

programmeradmin1浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 1

You 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();
发布评论

评论列表(0)

  1. 暂无评论