0

I am trying to display the user_registered date from get_user_meta but it always displays as empty. If I try another field I do get a value so not sure why I don't see anything for the date. If I check the database there is definitely a date.

$data = array();
$user_query = new WP_User_Query( array( 'meta_key' => 'location', 'meta_value' => $my_location, 'orderby' => 'meta_value_num', 'order' => 'DESC' ));
$authors = $user_query->get_results();
     foreach ($authors as $user) {
        $register_date = get_user_meta($user->ID, 'user_registered', true);

         $data[] = array(
             'registered' => $register_date,
         );
}
return $data;

1 Answer 1

2

user_registered is not a meta field, it is a field in the users table.
Try:

$register_date = $user->user_registered;
1
  • Brilliant, thanks! Commented Jul 2, 2021 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.