First remove the category metabox from the post edit screen for this particular role, let’s name it onecat-author
:
if (current_user_can('onecat-author')) {
remove_meta_box ('category', 'post', 'normal');
}
Next, when the post is saved use the available hook to assign the category:
if (current_user_can('onecat-author')) {
add_action ('save_post', 'wpse_231846_save_cat', 10, 1 );
}
function wpse_231846_save_cat ($post_id) {
wp_set_post_categories ($post_id, array('the-id-of-that-category'));
}
Note: the code is untested, so some debugging may be necessary.
Related Posts:
- each user having category with their name and can add sub categories post in that category
- Add role that restricts user to post in specific category
- Get user’s most published categories
- Stop users posting into category while still seeing contents of the category
- How to allow users to post only in certain category and hide elements from edit page?
- Hide comments and posts posted by other user
- Is there a way to save different data when USER interacts with the same POST?
- How to display particular categorie’s post which associated to specific user?
- Admin Post List Only Show One Category
- Delete old post with new post
- Automatically select category based on user role
- How to get the number of posts in a selected category?
- Category checkbox list tree changes when editing a post
- Show related posts by category but ignore one category
- Single.php Active Category Class
- Navigation link to specific user page
- Most efficient way to list all categories and display a post for each of them?
- Add custom field to category of custom post type
- Can I hide a specific post from latest posts page?
- Multiple authors for single post without plugin
- How to show post(excerpt) from specific category on wp page?
- WordPress – Admin Manage Posts – Multiple Filters by Parent Category
- Custom Theme Want To Remove One Category From All Displays
- Allow anonymous users to post to my site for moderation
- Divide Loop Into Days & Categories
- Different template for posts of all subcategories of category
- Mark menu item as current-menu-item for category
- How to set up multiple taxonomies for groups of posts
- How to filter posts that belong to a specific category only if that is the only category
- Category List (Archive) Page Template By Category
- How to display category from recent posts?
- Can I divide the pages into categories?
- How to allow logged in users to post anonymously
- Duplicate posts and change category
- Category Foreach keeps looping?
- Hiding posts by other users and non-logged in
- display a random post thumbnail from a random category
- How can i limit the number of posts created per category?
- Post page to display specific category
- Post visibility based on user role
- how to show single post in a custom template
- How can I hide tags on a child-category page, if that tag has not been used?
- How do I stop the loop from repeating in my category template?
- Excluding posts not working
- post category in wp_insert_post
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- (solved) getting post author’s user role
- Remove current category from post but display all others
- How do I show posts from another wordpress installation?
- How do I include the category next to the title of a post?
- How to show a custom taxonomy in the theme?
- How to import nested categories from XML file?
- How to get post with associated categories and tags names instead of ids with rest api?
- Migrate posts from category and sub-category via SQL
- Posts Missing in Dashboard after update
- Display post number by category
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- How to get post with slug and exclude categories
- Mutliple users editing single document in wordspress
- Retrieving posts by their date and category
- Are post, page and category IDs unique to each other?
- Static pages not working
- WordPress displays post on subcategory only
- Cannot select certain authors for posts after import
- How to list post as buch of category, and all of them
- How can I add a page that shows posts from a single category?
- Categories Listing and Highlighting current category item
- Display hierarchical categories/sub-categories for a single post only
- Remove subcategory slug from url
- Author post count in category
- Current post categories and subcatecories outside of the loop
- Why do I have categories with duplicate slugs?
- WordPress Delete Users from backend doesn’t work
- Automatic Table of contents with categories and posts
- Custom post styling per category?
- Is it possible to remove actual post pages in wordpress but keep them in categories
- Need help with hiding an image within a post in a category
- WordPress not showing recent posts
- List Authors For Current Category
- List posts of assigned categories in list of all categories on single.php
- User rank in wordpress post
- Allow users to create their own page/s
- Get current user array with post string
- Assign specific ads to specific categories/posts
- find posts with exactly 3/4 categories
- Use radio buttons & checkboxes for post categories
- Displaying only posts from a certain category on my custom page template
- I need to create a page or post hierarchy
- Separate categories parents, childs and grandchilds in dropdowns
- WP_Query: Fetch posts that are in (category1 and not in category2), OR posts that are not in cagegory1
- Add default content to post (for specific category)
- List posts that are in the same category as the current post title
- WordPress strips some attributes for author posts
- The post order is different for logged-in and non-logged-in users? [closed]
- Multiple blog “feeds” in a single blog each with distinctly styled post pages
- How to get pagination working with “Pending” Posts
- Taxonomy Category category.php not working
- Post’s arent displaying
- Show with echo if a post has two or more categories
- How can I get on the same row two post of different categories?