Add hierarhical managment
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Plugin Name: User Organizations
|
||||
* Plugin URI: https://wordpress.org/plugins/wp-user-groups/
|
||||
* Author: Saburly
|
||||
* Description: Hierarchical organization managment
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
function load() {
|
||||
if (class_exists('WP_User_Taxonomy')) {
|
||||
require_once ('includes/class_user_organization_taxonomy.php');
|
||||
require_once ('includes/class-user-organizations-directory.php');
|
||||
require_once('includes/class-order-managment.php');
|
||||
|
||||
apply_filters('user_organizations_loaded');
|
||||
}
|
||||
}
|
||||
|
||||
function remove_default_user_groups() {
|
||||
remove_action( 'init', 'wp_register_default_user_group_taxonomy' );
|
||||
remove_action( 'init', 'wp_register_default_user_type_taxonomy' );
|
||||
}
|
||||
|
||||
function fetch_user_organization() {
|
||||
return User_Organizations_Directory::get_user_organization();
|
||||
}
|
||||
|
||||
add_action('init', 'load');
|
||||
|
||||
add_action('plugins_loaded', 'remove_default_user_groups', 30);
|
||||
|
||||
add_action('user_organizations_loaded', function() {
|
||||
register_rest_route('wiaas/v1', '/organization', array(
|
||||
'methods' => 'GET',
|
||||
'permission_callback' => 'check_permission',
|
||||
'callback' => 'fetch_user_organization',
|
||||
));
|
||||
});
|
||||
Reference in New Issue
Block a user