I'm trying to add code to my themes functions.php to display fields created with the Cimy user extra fields plugin in the dashboard users.php. I know that I need to use manage_users_columns, but beyond that I'm stuck. Anyone familiar enough with the plugin to help me get the proper fields to display?


A couple thoughts that might help you or others reading this...

FWIW, the priority parameter doesn't have an effect unless you have multiple functions that you're attaching to the hook. So, 15 or 1 or 9999 is irrelevant. In case you might be thinking the priority has anything to do with column order, it doesn't.

Also, you can attach the 'theme_column_userfield' function to the manage_users_columns hook with add_action...it works the same either way. ie.,

add_action('manage_users_columns', 'theme_column_userfield');

works the same.

Lastly, the code block doesn't include any sort of ordering. Done this way, the column will be added to the right side of the table. If you need to insert the column somewhere you'll need to use a little bit or a lot of array_slice and array_merge depending on how simple/complex/reusable you need to be.

For example, if you used this...

    function add_new_column($column_headers) {
        // slice off the checkbox column
        $cb_col = array_slice($column_headers, 0, 1);

        // create the new column (you could add in translation if you want it)
        $new_col    = array('new_column_name' => 'New User Column');

        // stick it all back together
        $column_headers = array_merge($cb_col, $new_col, $column_headers);

        return $column_headers;
    add_action('manage_users_columns', 'add_new_column');

    function output_new_column($value, $column_name, $id) {
        if($column_name == 'new_column_name') {
            // add some code here to print out whatever value you want in whatever style you're after
    add_action('manage_users_custom_column', 'output_new_column', 1, 3);

...the 'New User Column' would appear right after the checkbox in the Users list, followed by all of the rest of the default columns.


I hacked my way into figuring this out. Here's the code for reference:

function theme_column_userfield( $defaults ) {  
      $defaults['theme-usercolumn-userfield'] = __('fieldname', 'user-column');  
      return $defaults;  

function theme_custom_column_userfield($value, $column_name, $id) {  
      if( $column_name == 'theme-usercolumn-userfield' ) {  
            return get_cimyFieldValue($id, 'fieldname');  

add_action('manage_users_custom_column', 'theme_custom_column_userfield', 15, 3);
add_filter('manage_users_columns', 'theme_column_userfield', 15, 1);
  • @user2041 You should accept your own answer so that people know this is resolved.
    – MathSmath
    Dec 17 '10 at 20:47
  • Is this possible for custom post types like - add_action('manage_videos_custom_column', 'theme_custom_column_videofield', 15, 3); add_filter('manage_videos_columns', 'theme_column_videofield', 15, 1); Mar 8 '12 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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