Skip to content

Instantly share code, notes, and snippets.

@davidzack
Created March 20, 2017 23:25
Show Gist options
  • Save davidzack/da0dfdd0fe4725946003629ff548e812 to your computer and use it in GitHub Desktop.
Save davidzack/da0dfdd0fe4725946003629ff548e812 to your computer and use it in GitHub Desktop.
update expiration date
function daz_custom_field_on_publish( $new, $old, $post ) {
$unixtime = date(strtotime("+1 week"));
$now = date("m/d/Y",$unixtime);
if ( $new == 'publish' && $old == 'pending') {
update_post_meta( $post->ID, '_post_expiration_date', $now );
}
}
add_action( 'transition_post_status', 'daz_custom_field_on_publish', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment