There’s get_the_author_meta()
for such a task. (get_*
functions normally don’t echo/print the output – hence the name).
// Both values are *optional*
get_the_author_meta( $field, $user_id );
Normally it’s only meant to be used inside a loop to get the data of the posts author, therefore it internally uses global $authordata;
.
But, you can also throw in the data of the current user, as user data is always the same (same tables, same data).
global $current_user;
// Test to see what you get:
echo '<pre>'.var_export( $current_user, true ).'</pre>';
get_the_author_meta( '', $current_user->ID );
// OR: simply, without the global
get_the_author_meta( '', get_current_user_id() );
Now the only thing left is to call the meta for each field, using get_user_meta()
, which is pretty much equal (for this task) to get_the_author_meta();
.
$user_meta = get_user_meta( get_current_user_id() );
// OR: Use the function, where get_user_meta() is the API wrapper for
$user_meta = get_meta_data( 'user', get_current_user_id(), '', true );
Then just loop through it:
foreach ( $user_meta as $meta_data )
echo '<pre>'.var_export( $meta_data, true ).'</pre>';