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;
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
user_registered is not a meta field, it is a field in the users table.
Try:
$register_date = $user->user_registered;
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0