Why does each user need their own category?
Because they are 50 finance professionals with their own clients and confidential information. We are intranet private blog. Only authors will have the opportunity to create their categories. I think they will have about 50 authors. Can you help me?
I was asking because author links and feeds already exist with things like /author/name so, why do they need categories specifically? Seems like you have a problem that you’re trying to solve with the wrong answer.
Yes that’s right, but in this case the contributor uses Postie’s plugin to publish a post by email. With the Postie category option in the topic, this will allow the contributor to publish directly into the author category, if I can find the code to do that. Currently I have the code for the role condition, it misses me the category code by autheur (like the example above). I have this problem because contributors use Postie plugin, it’s the easiest way for them to publish a post.
Use case is: 1-New author registers on the site. 2-The new suscriber publishes in the category of the author name, into the title (Postie Plugin)
(Author Category Plugin do manualy the category association in the user profil.)
The code below works well for category creation in a post.
add_action(‘save_post’, ‘add_title_as_category’);
function add_title_as_category( $postid ) {
if ( defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE ) return;
$post = get_post($postid);
if ( $post->post_type == ‘post’) { // change ‘post’ to any cpt you want to target
$term = get_term_by(‘slug’, $post->post_name, ‘category’);
if ( empty($term) ) {
$add = wp_insert_term( $post->post_title, ‘category’, array(‘slug’=> $post->post_name) );
if ( is_array($add) && isset($add[‘term_id’]) ) {
wp_set_object_terms($postid, $add[‘term_id’], ‘category’, true );
}
}
}
}