How to disable saving/changing update date for certain admin users?

I have an admin user who is only for correcting the spelling errors and grammar stuff, however, when he corrects some post that is several hours or days old and just changes “People are gready” to “People are greedy” in the title or makes some other changes in the content, the update date is changed and I don’t want that to happen.

Is there any build-in WP function that I can use that for some users e.g. for user with ID 14 and 19. Any idea how to do that?

Related posts

1 comment

  1. 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.

Comments are closed.