Awesome!! Tks a lot @threadi
@threadi I’m back again 🙂
So I added the following code but nothing I’m not getting any change, it is like the action is not being executed
do_action( "save_post", 'saveBlockTime', 10, 2);
function saveBlockTime($post_id, $post ) {
/*if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE){
return;
}*/
update_post_meta(7143, 'trip', 150);
$message = "hoursss ".get_field('flight_hours', $post_id);
wp_mail("email@gmail.com", "flight", $message );
}
do_action( 'wp_trash_post', 'saveBlockTime', 10);
FYI I’m adding this code to functions.php
uhh just found out I had to change do_ with add_
add_action( "publish_block-time", 'saveBlockTime', 20, 2);
@threadi now I have a new issue, when I use this code
add_action( "publish_block-time", 'saveBlockTime', 10, 2);
I can print the post ID but I can’t print any meta_data it seems that it is being called before the meta is saved, same thing happens if I use save_post… do u know what action I have to use or priority to get the meta_data when a post is published?
Just an update about the publish post I got here and I’ll create another topic about delete it.
add_action( "publish_block-time", 'saveBlockTime', 10, 2);
function saveBlockTime($post_id, $post ) {
$pilot = $_POST['acf']["field_641868dba4ea7"];
$getCurrentHours = get_field('block_time', 'user_'.$pilot);
$calculateBlockTime = intval($getCurrentHours)-intval($_POST['acf']["field_641867f757fe8"]);
update_user_meta($pilot, 'block_time', $calculateBlockTime);
}
do u know what action I have to use or priority to get the meta_data when a post is published?
Which meta do you mean? postmeta? Its saved before ‘save_post’-hook is called. You did use another hook.