Tagged: admin column, user taxonomy
- This topic has 4 replies, 2 voices, and was last updated 7 years, 4 months ago by
Steve.
Viewing 4 reply threads
-
AuthorPosts
-
-
September 9, 2014 at 6:19 am #2400
norbooMemberHi!
I created a user taxonomy but I’m having problems showing it in the Admin Column (All users)| Username | Name | Role | User Type??? |
This is the code I have in the functions.
// Piklist Custom Taxonomies add_filter('piklist_taxonomies', 'piklist_custom_taxonomies'); function piklist_custom_taxonomies($taxonomies) { $taxonomies[] = array( 'object_type' => 'user' ,'name' => 'user_type' ,'show_admin_column' => true ,'configuration' => array( 'hierarchical' => true ,'labels' => piklist('taxonomy_labels', 'User Type') ,'show_ui' => true ,'query_var' => true ) ); return $taxonomies; }Another problem is when I delete an user the Users count for the taxonomy term is not updated.
-
September 10, 2014 at 8:23 pm #2426
norbooMemberAnyone?
-
September 11, 2014 at 12:15 pm #2429
SteveKeymaster@norboo– Sorry for the late reply. Pikilst doesn’t support this yet, but since Piklist does everything the WordPress way, you can easily add this using standard WordPress actions. Place code in your main plugin file, or your themes functions.php. It should look like this when viewing the User List.
add_filter('manage_users_columns', 'user_column_header', 10, 2); add_action('manage_users_custom_column', 'user_column_data', 10, 3); function user_column_header($columns) { $columns['user_type'] = __('User Type'); return $columns; } function user_column_data($term_list, $column, $value) { switch ($column) { case 'user_type': $term = wp_get_object_terms($value, 'user_type'); if(isset($term[0])) { $prefix = ''; foreach ($term as $name => $value) { $term_list .= $prefix . $value->name; $prefix = ', '; } } else { $term_list = ''; } break; default: $term_list = ''; break; } return $term_list; } -
September 15, 2014 at 4:40 am #2435
norbooMemberThanks Steve!
Works like a charm! -
September 15, 2014 at 9:59 am #2436
-
-
AuthorPosts
Viewing 4 reply threads
- The topic ‘User Taxonomy in Admin column’ is closed to new replies.