0

I want to get the users who registered within last 7 days, and meanwhile who have uploaded custom avatar. I've added a function allowing users to upload their own avatar img with a custom field simple_local_avatar.

What I have done so far,

$args = array(
                'number' => 10,
                'orderby' => 'registered',
                'order' => 'ASC',
                'meta_query' => array(
                    array(
                    'key' => 'simple_local_avatar',
                    'value' => '',
                    'compare' => '!='
                    )
                ),
                'date_query' => array( 
                    array( 'after' => '1 week ago', 'inclusive' => true )  
                )
);

Through my above code, I can only get users registered over last seven days, but it cannot filter the ones who haven't uploaded custom avatar.

Any help with this? Appreciate.

My solution:

$args = array(
                'number' => 10,
                'orderby' => 'registered',
                'order' => 'DESC',
                'meta_query' => array(
                    array(
                    'key' => 'simple_local_avatar',
                    'compare' => 'EXISTS'
                    ),
                    array(
                    'key' => 'simple_local_avatar',
                    'value' => '',
                    'compare' => '!='
                    )
                ),
                'date_query' => array( 
                    array( 'after' => '1 week ago', 'inclusive' => true )  
                )
            )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.