Last active
June 14, 2021 04:07
-
-
Save kevinchappell/496a62c2d2b108bac7e8 to your computer and use it in GitHub Desktop.
Get all User data in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get an array of all user data | |
* @param string|int $user_id | |
* @return array merged array of user meta and data | |
*/ | |
function get_user_data( $user_id ){ | |
$user_data = (array) get_userdata( $user_id )->data; | |
$user_meta = array_map( function( $item ){ return $item[0]; }, (array) get_user_meta( $user_id ) ); | |
return array_merge( $user_data, $user_meta ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment