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 allow Contributors to edit their own posts, whilst still needing to be reviewed by an admin?
- How to display two blog categories as separate sections on one page?
- How to make the first post in the loop be styled like a “new / featured” post?
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- How do I stop the loop from repeating in my category template?
- get_the_category listing in hierarchial order
- How do I manage my users post before publish?
- Is it possible to add/tick a category to a post when it is created?
- Excluding posts not working
- How do I retrieve a users’ last 5 posts?
- Gather posts into a cart/lightbox and share with another user
- Hide posts belongs to few categories in homepage
- why does wordpress ignore the post args?
- 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
- How to get subcategories from category slug?
- Remove current category from post but display all others
- How show categories in admin and get that selected to show posts in index
- Delete post after x minutes if user role is
- Showing categories and subcategories with posts
- Change default category when I publish a post
- store posts_id of category into a varable?
- Show posts by author of membership level (Paid Membership Pro)
- Assign published posts to another user automatically
- How to display two random-post sections that are each under their own category
- How can you display all sibling categories to a post?
- Loop doesn’t exclude the specified category in home page
- Display posts of specific category term
- Add field to user meta table in database when link is clicked
- Widget that shows categories with posts numbers
- How to create a sub post?
- Post Image not displaying in category view
- Automatically create a default set of posts for each new registered user
- How do I show posts from another wordpress installation?
- get posts from Custom Post Type & Category
- Category page when using static front page
- Latest posts by category — how to exclude current post?
- How do I include the category next to the title of a post?
- Relative number of post in category
- How to create a “latest news” page showing a list of posts from blog category
- Summary of Posts by an User
- WordPress bulk category select when publishing post
- Exclude some categories from listing on the current post
- How to show a custom taxonomy in the theme?
- How to import nested categories from XML file?
- how to hide empty fields of post category description?
- Display a list of users who have viewed the post you are viewing
- how can i display my posts alphabetically?
- if in category but only with post meta
- How to get post with associated categories and tags names instead of ids with rest api?
- Check if current user has a post and that post has any term/s from a specific custom taxonomy outside the loop
- Display a mixed list of posts and media
- Migrate posts from category and sub-category via SQL
- Parent category / child category posts
- Posts Missing in Dashboard after update
- Echo Text If User Is Logged in But NOT the Author of post
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Sort by last word in title
- Display post number by category
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- singular posts using archive styling
- Change Post Title For Specific Category
- Display selected categories onto post page
- How to call posts under a specific category on static front page?
- Give posts a particular template based on the assigned category
- How to have more than one page for your posts if you have 8 posts but can store max 4 on a page
- Extract wordpress posts content and category content
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- How to get post with slug and exclude categories
- All categories displays the same posts
- Having pages after specifying post_type post
- Show number of posts by logged in user
- Mutliple users editing single document in wordspress
- Unable to differentiate between two categories under custom post type on single.php
- In what context should Categories and Tags be used
- Exclude post category in a blog page
- Show posts on front page only
- list posts from two categories on a page – plugin not working
- Retrieving posts by their date and category
- Get latest post from categories
- How to create a playlist for audio associated with posts per category
- Are post, page and category IDs unique to each other?
- Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
- Change the background of each post according to the category
- Static pages not working
- Post-Archive like a page in a specific subdirectory