Advertisement
helgatheviki

Register User Taxonomy

Jun 30th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. add_action( 'init', 'my_register_department_taxonomy' );
  2. /**
  3. * Registers the 'department' taxonomy for users. This is a taxonomy for the 'user' object type rather than a
  4. * post being the object type.
  5. */
  6. function my_register_department_taxonomy() {
  7.  
  8. register_taxonomy(
  9. 'department',
  10. 'user',
  11. array(
  12. 'public' => true,
  13. 'labels' => array(
  14. 'name' => __( 'Departments' ),
  15. 'singular_name' => __( 'Department' ),
  16. 'menu_name' => __( 'Departments' ),
  17. 'search_items' => __( 'Search Departments' ),
  18. 'popular_items' => __( 'Popular Departments' ),
  19. 'all_items' => __( 'All Departments' ),
  20. 'edit_item' => __( 'Edit Department' ),
  21. 'update_item' => __( 'Update Department' ),
  22. 'add_new_item' => __( 'Add New Department' ),
  23. 'new_item_name' => __( 'New Department Name' ),
  24. 'separate_items_with_commas' => __( 'Separate departments with commas' ),
  25. 'add_or_remove_items' => __( 'Add or remove departments' ),
  26. 'choose_from_most_used' => __( 'Choose from the most popular departments' ),
  27. ),
  28. 'rewrite' => array(
  29. 'with_front' => true,
  30. 'slug' => 'author/department' // Use 'author' (default WP user slug).
  31. ),
  32. 'capabilities' => array(
  33. 'manage_terms' => 'edit_users', // Using 'edit_users' cap to keep this simple.
  34. 'edit_terms' => 'edit_users',
  35. 'delete_terms' => 'edit_users',
  36. 'assign_terms' => 'read',
  37. ),
  38. //'update_count_callback' => 'my_update_user_term_count' // Use a custom function to update the count.
  39. )
  40. );
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement