A bare-bones version would look something like:
function deny_post_date_change_wpse_131049( $data, $postarr ) {
$user = wp_get_current_user();
// var_dump($user); die; // debugging
if (in_array($user->ID,array(14,19))) {
unset( $data['post_date'] );
unset( $data['post_date_gmt'] );
}
return $data;
}
add_filter( 'wp_insert_post_data', 'deny_post_date_change_wpse_131049', 0, 2 );
I expect that in practice you probably want more complicated logic but that should get you started.
Related Posts:
- wp_update_post() example… how to update the_content in a textarea?
- Why wp_update_post() does not update GUID?
- What are the limitations of wp_update_post()?
- I need to bulk update all wordpress posts on a scheduled time
- wp_update_post does not update post_name
- What’s the proper way to use a custom table? [closed]
- Adding action to save_post, post needs to be saved twice for function to work
- “Internal Server Error” with wp_update_post
- wp_update_post using post_name
- how to get last revision id created after wp_update_post
- why wp_update_post cant update when value is empty?
- update a post with wp_update_post
- Updating posts not working
- Update a post’s info when clicking on a javascript button
- What ‘function’ will ‘update’ a post?
- Clear cache on post of one type when something happens to post of other type
- wp_update_post meta causing 500 error
- Updating post_parent by id (many times)
- wp_update_post making my post sticky
- How to keep a record of changes to a custom field?
- Is it possible to “Update” pages via SQL?
- Update post meta is slow while saving post
- Update post (published) date when changing category
- recursively update content
- wp_update_post ignores if/else
- $wpdb->update query incrementing value on it’s own!
- save_post affect creation and deletion
- Update button (sometimes) greyed-out
- Set a post to draft once depending on a post meta value (passed certain date)?
- wp_update_post behaves differently for different user role
- Fatal error: Call to undefined function wp_cache_get after update attempt
- BuddyPress Edit activity function good practice
- Best collection of code for your 'functions.php' file [closed]
- How to: Easily Move a WordPress Install from Development to Production?
- Is moving wp-config outside the web root really beneficial?
- Hide the fact a site is using WordPress?
- Objective Best Practices for Plugin Development? [closed]
- Organizing Code in your WordPress Theme's functions.php File?
- What does this PHP function code mean? [closed]
- similar of my posts in all over the internet sites and blogs [closed]
- When to use is_home() vs is_front_page()?
- Is there a flowchart for WordPress loading sequence?
- How to change the default registration email ? (plugin and/or non-plugin)
- Best collection of code for your .htaccess file [closed]
- MySQL Database User: Which Privileges are needed?
- Essential technical features for high-end WordPress web hosting? [closed]
- How to structure a plugin
- How to remove admin menu pages inserted by plugins?
- How to create a custom search for custom post type?
- Opinions and recommendations on the best barebones base theme [closed]
- How to put logs in WordPress
- How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?
- Conditionally Loading JavaScript/CSS for Shortcodes
- What is your best practice to execute one-time scripts?
- How to get the Date Format and Time Format settings for use in my template?
- Database synchronization between dev/staging and production
- what is the correct way to compare dates in a WP query_posts meta_query
- Explanation of update_post_(meta/term)_cache
- How to implement a customizable free OpenID authentication?
- Should all plugins be encapsulated in a Class?
- Add validation and error handling when saving custom fields?
- Best way to eliminate xmlrpc.php?
- Nested meta_query with multiple relation keys
- How To Add Custom Form Fields To The User Profile Page?
- Add multiple custom fields to the general settings page
- What SQL Query to do a simple find and replace
- What Features would you Most Like to See Added to WordPress? [closed]
- Why have on every line
- Where are Additional CSS files stored
- How can I edit post data before it is saved?
- How do i best handle custom plugin page actions?
- add_action(), add_filter() before or after function
- is_plugin_active function doesn’t exist
- Check for update vs new post on save_post action
- Best Practices for Regression Testing WordPress Websites?
- numberposts? showposts? posts_per_page?
- Remove wrapping div and ul from output of wp_nav_menu
- Attaching taxonomy data to post with wp_insert_post
- What Is The Use Of map_meta_cap Filter?
- How do you use a CPT as the default home page?
- How to create an API for my plugin?
- Is it ever okay to include inline CSS in plugins?
- Plugins in symlinked directories?
- get post author id outside loop
- Difference between add_filter and apply_filters
- How can I make updates to a site, on a development copy, but then move updates back without overriding live site’s evolving database?
- Custom pages with plugin
- Proper Way to Modify Plugin
- Custom Walker: how to get ID in function start_lvl
- Pass boolean value in shortcode
- How to add crossorigin and integrity to wp_register_style? (Font Awesome 5)
- Customizing a WordPress theme without changing it?
- Creative uses of WordPress [closed]
- How to avoid infinite loop in save_post callback
- Can a custom post type have a Parent Page?
- Restrict custom post type to only site administrator role
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- Best practices for localizing WordPress content?
- Plugin Form Submission Best Practice
- How to *remove* a parent theme page template from a child theme?