Last active
December 31, 2015 13:25
-
-
Save JPry/2e4b074a81d7c8234eb4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: wp_insert_post_data example | |
* Plugin URI: https://gist.github.com/JPry/2e4b074a81d7c8234eb4 | |
* Description: Example of prevnting the modified date from changing. | |
* Version: 1.0 | |
* Author: Jeremy Pry | |
* Author URI: http://jeremypry.com/ | |
* License: GPL2 | |
*/ | |
// Prevent direct access to this file | |
if ( ! defined( 'ABSPATH' ) ) { | |
die( "You can't do anything by accessing this file directly." ); | |
} | |
add_filter( 'wp_insert_post_data', 'jpry_filter_insert_post_data', 10, 2 ); | |
function jpry_filter_insert_post_data( $data, $postarr ) { | |
// Only strip the modification time for Administrator role. | |
if ( 'bil' === $data['post_type'] && current_user_can( 'administrator' ) ) { | |
unset( $data['post_modified'] ); | |
} | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment