This is an improvement on my last attempt.
I use the plugin ‘Enhanced Media Library’ as I can view each of the categories individually.
This routine creates a separate category for each user, or it could be product or item etc. This routine just needs to be run once for each user, probably at joining.
The next stage is to allocate each image to the defined category for that user which will give a totally organised media library (sort of…).
I’m hoping Roland will give me a few pointers for this next stage.
Thanks
$current_user = wp_get_current_user();
$wp_username = $current_user->user_login;
$user_id = Participants_Db::get_record_id_by_term('username', $wp_username);
$data = Participants_Db::get_participant($user_id);
$first_name = $data['first_name'];
$last_name = $data['last_name'];
$boat_name = $data['boat_name'];
$boat_model = $data['boat_model'];
$parent_name = 'Members Boats';
$my_category = $boat_name.' ['.$user_id.']';
$my_description = $first_name.' '.$last_name.' ['.$boat_model.']';
function insert_category ($category,$description,$parent) {
$parent_term = term_exists($parent,'media_category');
$parent_term_id = $parent_term['term_id'];
wp_insert_term(
$category,
'media_category',
array(
'description' => $description,
'slug' => $category,
'parent' => $parent_term_id,
)
);
}
insert_category($my_category,$my_description,$parent_name);