This is my function:
function investment_save($post_id)
{
$post = get_post();
$date = $post->post_date_gmt;
$moddate = $post->post_modified_gmt;
if($date == $moddate)
{
$field_key = "datos_especificos";
$value = get_field($field_key, $post_id);
$value[] = array("fecha" => get_field('fecha_de_inicio_de_la_inversion'),
"saldo" => get_field('monto_de_la_inversion'),
"inversion_en_el_periodo" => "0",
"interes_causado_en_el_periodo" => "0",
"cantidad_pagada" => "0");
update_field( $field_key, $value, $post_id );
}
}
add_action( 'save_post or post_updated', 'investment_save' );
Save_post doesnt work because it triggers when pressing “New Post”, and it tries to add information that doesnt exist into my advance custom field’s Repeater which ends up with the browser freezeing for like a minute.
Post_updated doesnt work because it seems like custom post types make this hook work differently for no aparent reason.—> Trying to get wordpress hook post_updated to work
My code intends to create ONE row with the information just added in the post, ONLY when pressing publish (NOT when pressing update and NOT when pressing “New post”)
Is there any way to use any of this hooks correctly, use a different hook, or something completely different to add the info that was added in the post as a row in the Repeater(acf).