You can hook into the pre_post_update
action hook, and check both post’s category and editor. Here’s a quick example:
// Hook to save_post to do some checks
add_action( 'pre_post_update','wpse315124_save_post_check' );
function wpse315124_save_post_check( $post_id, $post_data ){
// Check user's role and post's category
if(
has_category ( 'some-category', $post_id ) &&
current_user_can( 'editor' )
) {
// Stop the script
wp_die( __( 'You can not edit this post.' ) );
}
}
You can also run additional tests, such as get_current_user_id()
and check the id to match specific users/categories.
Related Posts:
- Category’s Description field as editor remove tag
- How to view Plugin Manager in Notepad++
- Is there a plugin that provides a stackoverflow style editor for wordpress? [closed]
- How to Display Product specific to a category with WooCommerce Plugin? [closed]
- How can I allow commas in tag names?
- Get the category from an ID of a product?
- How to add “Stick this post to the front page” to front end?
- Get a button for in the Editor
- How to enable edit button in the theme’s customize UI?
- Drag-and-drop “Panels”-style visual layout editor?
- Way to force media uploader use custom image size
- use WordPress theme / plugin editor in my plugin
- Disable text tab on WordPress text-editor
- Restrict individual category combinations
- Restrict access and display for categories
- Qtranslate displays empty categories with get_categories()
- Plugin for changing a post’s category based on it’s post date?
- Plugin to set all Posts in a certain Category to a certain Post Format
- Woocommerce category description as subtitle
- Get subcategories with JSON API plugin
- How to display a category list in a mediawiki like way?
- Give editors access to particular plugin – turn “admin.php” into “edit.php”
- How to show custom static content at top of each category page?
- How to use get_categories() with Event Organiser plugin
- Server-side subscribe by email?
- plugin for wp_list_categories with posts
- Set a category for a page
- How can I get the post content displayed in a text field that allows to edit posts?
- CKEditor: Uncaught TypeError: switchEditors.switchto is not a functiononclick
- Is there a plugin to insert pre-defined link into editor?
- How do you remove plugin edit option?
- Show Heirachy of categories in WP Download Monitor
- Custom Post Type Plugin not loading category template and loading 404 instead
- Display content from custom post type if match to main post category
- How can i list random post from multiple category?
- Support for simultaneous editing
- My Category is too big on the Menu what can i do?
- Getting a List of Categories for Use in a Plugin?
- Not able to open category post [closed]
- WordPress category add image field
- Advanced Custom Fields plugin – get text from editor field and save it in a variable
- WordPress JSON API remove posts from a specific category
- Easy Digital Download Sub category
- Solutions to repost categories into multisite blogs?
- How to display only subcategory
- Assign post format to categories
- Using WP Category Lists Plugin to Dynamically Display Category (PHP)
- Calendar Solution: Handling upcoming Dates with Posts?
- Events Plugin that works with existing categories?
- Excluding a category from wp_query breaks recent post widget
- Trouble with editing template for “List category posts” plugin
- Any built-in function to associate a post to category through a plugin?
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Display by Category in Admin
- Search for categories
- Set featured image using javascript in post editor
- Why is WPBakery Page Builder backend editor not clickable? [closed]
- Redirecting thousands of posts that currently have no category in their permalink when changing permalink structure to include category
- Customize permalink wordpress category id
- Delete mobile menu button [closed]
- Automatically Assign Author to Category [closed]
- Custom Pages for Woocommerce Product-Category Pages
- polylang + category/tag custom language link
- How to password protect a category page / not posts?
- Trouble adding tiny mce to textarea in custom plugin
- How to display taxonomy images with wp_list_categories?
- Using arbitrary paths in page urls
- WordPress “Categories to tags converter” not working. Pointing to import.php instead
- How do I apply style to each category of a list?
- Redirect to another page using contact form 7? [closed]
- Recent posts per category loop?
- How to add custom table style for table block in gutenberg editor
- Disable Plugin with one button
- How do I rename a category in the menu bar only?
- Ambrosite Next/Previous Post Link Plus or WP next_post_link to cycle through top level category
- Is changing post from category in a large blog a good practice?
- Best/Correct way to add an option to a category
- How to set category correctly for a custom post created by a remote API call?
- Is there a maximum length to a WordPress Page?
- How to add fields in the WordPress editor?
- Access post title from custom meta box on title change
- .php file for woocommerce edit category? [closed]
- check uncategorized category by default
- How to add HTML5 required on wp_editor
- Show WordPress Plugin Menu(Admin) To Editor
- Mutliple users editing single document in wordspress
- How to add category and subcategory in WordPress custom code?
- Plugin permissions for Editor role
- WooCommerce Hiding A Certain Category From Being Displayed On Single Product
- How can recognize post’s category?
- How can i listing current category and Featured Category post list?
- Role based permission edit for plugins
- Categories from front-end, checkbox selection doesn’t work
- Edit part of a post
- Is there a syntax highlighting plugin for HTML View? [duplicate]
- How to get Recent Post From Each Category with Thumbnail?
- Plugin for visitors to edit content without logging in? [closed]
- Category “same post” retreive and display
- How to check if the post exists in any of the categories?
- I have to select text from gutenberg editor. Purpose is to store and replace text