Created
March 20, 2017 23:25
-
-
Save davidzack/da0dfdd0fe4725946003629ff548e812 to your computer and use it in GitHub Desktop.
update expiration date
This file contains 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
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