Last active
July 25, 2025 10:59
-
-
Save mlbd/31ce06e07877d3c8ddbcd40bdff0f3fb 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
/** | |
* Action hook triggered when a user submits a post/page to workflow or completes a step. | |
* | |
* Updates the due date of the action history record to the global default due date set in | |
* the Workflow Settings tab, if the default due date is set. | |
* | |
* @param int $post_id The ID of the post/page being submitted. | |
* @param int $action_history_id The ID of the action history record being updated. | |
*/ | |
function custom_modify_due_date_on_submit($post_id, $action_history_id) { | |
global $wpdb; | |
$chk_default_due_days = get_option( 'chk_default_due_days' ); | |
$default_due_days = get_option( 'oasiswf_default_due_days' ); | |
if ( empty( $chk_default_due_days ) || empty( $default_due_days ) ) { | |
return; | |
} | |
$default_due_days = intval( $default_due_days ); | |
$global_due_date = date_i18n( 'Y-m-d', | |
current_time( 'timestamp' ) + DAY_IN_SECONDS * $default_due_days ); | |
// Update the record in fc_action_history | |
$table = $wpdb->prefix . 'fc_action_history'; | |
$updated = $wpdb->update( | |
$table, | |
array('due_date' => $global_due_date), | |
array('ID' => $action_history_id), | |
array('%s'), | |
array('%d') | |
); | |
} | |
add_action('owf_submit_to_workflow', 'custom_modify_due_date_on_submit', 20, 2); | |
add_action('owf_step_sign_off', 'custom_modify_due_date_on_submit', 20, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment