Giter Club home page Giter Club logo

lh-user-taxonomies's Introduction

=== LH User Taxonomies ===
Contributors: shawfactor
Donate link: http://lhero.org/plugins/lh-user-taxonomies/
Tags: user, users, taxonomy, custom taxonomy, register_taxonomy, developer
Requires at least: 3.0
Tested up to: 4.2
Stable tag: trunk

Simplify the process of adding support for custom taxonomies for Users. Just use `register_taxonomy` and everything else is taken care of.

== Description ==

This plugin extends the default taxonomy functionality and extends it to users, while automating all the boilerplate code.

Once activated, you can register user taxonomies using the following code:
`
register_taxonomy('profession', 'user', array(
	'public'		=>true,
	'single_value' => false,
	'show_admin_column' => true,
	'labels'		=>array(
		'name'						=>'Professions',
		'singular_name'				=>'Profession',
		'menu_name'					=>'Professions',
		'search_items'				=>'Search Professions',
		'popular_items'				=>'Popular Professions',
		'all_items'					=>'All Professions',
		'edit_item'					=>'Edit Profession',
		'update_item'				=>'Update Profession',
		'add_new_item'				=>'Add New Profession',
		'new_item_name'				=>'New Profession Name',
		'separate_items_with_commas'=>'Separate professions with commas',
		'add_or_remove_items'		=>'Add or remove professions',
		'choose_from_most_used'		=>'Choose from the most popular professions',
	),
	'rewrite'		=>array(
		'with_front'				=>true,
		'slug'						=>'author/profession',
	),
	'capabilities'	=> array(
		'manage_terms'				=>'edit_users',
		'edit_terms'				=>'edit_users',
		'delete_terms'				=>'edit_users',
		'assign_terms'				=>'read',
	),
));
`

Read more about [registering taxonomies in the codex](http://codex.wordpress.org/Function_Reference/register_taxonomy)
This is heavily inspired by previous work by [Justin Tadlock](http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress) and also forks Damian Gostomskis plugin in the repository to add additional functionality, including:

*Fixes a bug with display of existing user taxonomies in the user-edit screen
*Fixes a bug with taxonomy count in the old plugin where deleting users did not update the count
*Add support for 'single_value' attribute when registering a user taxonomy for taxonomies which should only have one value.
*Properly supports the capabilities associated with the taxonomy when registered.
*Supports 'show_admin_column' attribute when registering the taxonomy in the same way as post taxonomies.

Check out [our documentation][docs] for more information on how to register user taxonomies. 

All tickets for the project are being tracked on [GitHub][].


[docs]: http://lhero.org/plugins/lh-user-taxonomies/
[GitHub]: https://github.com/shawfactor/lh-user-taxonomies


== Installation ==

1. Upload the `lh-user-taxonomies` folder to the `/wp-content/plugins/` directory
1. Activate the plugin through the 'Plugins' menu in WordPress
1. Use `register_taxonomy` as shown in the description


== Changelog ==

**1.0 February 28, 2015**  
* Initial release

**1.2 July 15, 2015**  
* Code improvements

**1.3 July 17, 2015**  
* Documentation links

lh-user-taxonomies's People

Contributors

lindesvard avatar shawfactor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lh-user-taxonomies's Issues

Clash with BuddyPress?

There seems to be a minor clash with BuddyPress. BP registers a taxonomy called bp_member_type which is non-public, and is assigned to the user object. I'm not sure of the ins and outs of what BP does with this, but it ends up in this plugin's self::$taxonomies array, which I'm not sure it's supposed to, and causes all manner of PHP notices and warnings because the right properties aren't defined.

Edit User Taxonomy opens "Posts" admin menu

Registered new custom User Taxonomy called "Groups"
Created new Group called "Managers"
Clicked on "Edit" under the new Managers Group
"Posts" admin menu gets highlighted and expanded instead of remaining under Users-->Groups

Removing term from User

If a single taxonomy term is assigned to a user, that taxonomy term cannot be taken away.
With a normal post, when all taxonomy terms are removed, the post is assigned to the Uncategorized category. Since there is not, by default, an Uncategorized term on the custom taxonomy, it re-selects the taxonomy term that was originally chosen and cannot be unselected until another taxonomy term is selected for the user.
My workaround for now was to create a NotAssigned taxonomy term and assign that whenever I needed to remove all other terms.

Not working after last wordpress update?

After upgrading to the current version of wordpress 4.7 registering a taxonomy does not seem to work any more.

Current code does not produce any errors, but the taxonomy is note registered, can't be seen int backend, etc.

add_action('set_current_user', function () {
    write_log('registering taxonomies');
    register_taxonomy('team', 'user', array(
        'public'            => true,
        'single_value'      => true,
        'show_admin_column' => true,
        'labels'            => array(
            'name'                      =>'Teams',
            'singular_name'             =>'Team',
            'menu_name'                 =>'Teams',
            'search_items'              =>'Search teams',
            'popular_items'             =>'Popular teams',
            'all_items'                 =>'All teams',
            'edit_item'                 =>'Edit team',
            'update_item'               =>'Update Team',
            'add_new_item'              =>'Add New Team',
            'new_item_name'             =>'New Team Name',
            'add_or_remove_items'       =>'Add or remove teams',
            'choose_from_most_used'     =>'Choose from the most popular teams',
        ),
        'capabilities'      => array(
            'manage_terms'              =>'edit_users',
            'edit_terms'                =>'edit_users',
            'delete_terms'              =>'edit_users',
            'assign_terms'              =>'edit_users',
        ),
    ));
}, 10);

YOAST conflict

When the plugin YOAS SEO is activated this plugin stops working.

The registered user taxonomy stops appearing all together in the admin panel.

Please let me know if there is any other information you would like to help resolve this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.