This is code I set on function.php I made it to have original author's nickname as custom value.
function data_nickname( $post_id, $post, $update ) {
$data_nickname = get_post_meta($post->ID, 'data_nickname', true);
if(empty($data_nickname)):{
$author_ID = $post->post_author;
$data_nickname = get_the_author_meta('nickname',$author_ID);
update_post_meta( $post_id, 'data_nickname', $data_nickname, true );}
endif;
}
add_action( 'wp_insert_post', 'data_nickname', 10, 3 );
Author's nickname is sometimes kept as custom value as I expected, but also nickname of modified author is kept most of time.
I only like to keep original author's nickname. Not modified author.
How I can correct my code?