WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I checked justin tadlocks custom profile field tutorial and wanted to add the field in the custom dashboard widget but it seems it's not working. I want to show all the user information in this widget.

All that I want to do is add the custom information from the profile field to this dashboard widget and it seems to be not working.

My aim here to to get all author information and show it on this dashboard. Any ideas how to achieve this task?

function example_dashboard_widget_function() {
// Display whatever it is you want to show

// Create the function use in the action hook
function example_add_dashboard_widgets() {
wp_add_dashboard_widget('example_dashboard_widget', 'User Profile',    'example_dashboard_widget_function');
// Hoook into the 'wp_dashboard_setup' action to register our otherfunctions
add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' );
share|improve this question
Normally this should be (because of the wrong usage of the_author_meta()), just be closed as "too localized", as the question just comes out of the lack of a) reading the documentation and b) trying to fix it, but as I just stumbled upon something with the same target and a working solution, I close vote "duplicate". – kaiser Jul 29 '12 at 12:24
I tried reading the documentation. I didn't find a way to fetch all user information fields. So used the_author_meta. I thought it could even fetch the custom fields too. – Ryu Jul 29 '12 at 12:26
Take a look at my answer ↓ ... – kaiser Jul 30 '12 at 14:01
up vote 1 down vote accepted

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>';
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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