仅在条件下运行函数

i want to run this function only if the current logged in user is the post author

global  $user_ID;
$admin_user = get_user_by( 'id', $user_ID );
$selected   = empty( $post->ID ) ? $user_ID : $post->post_author;

function return_custom_price( $post ) {
global $post;
$new_total = get_post_meta( $post->ID, '_total_egp', true);
$price = get_post_meta($post->ID, '_regular_price', true);
//$sale_price = get_post_meta($post->ID, '_sale_price', true);
$now_price = get_post_meta($post->ID, '_price', true);
$woo_usd_rate = get_post_meta( $post->ID, '_usd_rate', true);
$woo_price_usd = get_post_meta( $post->ID, '_price_usd', true);
$cog = $woo_price_usd * $woo_usd_rate;

if($user_ID == $selected ){

update_post_meta($post->ID, '_regular_price', $new_total);
update_post_meta($post->ID, '_sale_price', '');
update_post_meta($post->ID, '_price', $new_total);
update_post_meta( $post->ID, '_wc_cog_cost', $cog );

}
}

add_action('save_post', 'return_custom_price');

this is what i've tried but it isn't working, and it ran anyway

what i'm trying to do is that when users post to wordpress using woocommerce from frontend, the posted post is added to wordpress in draft state, and admins just publish/approve the posts

what's happening right now is that in anyway if the admin clicked on publish the function runs and updates the post metas, i don't want to update the post metas unless if the admin who publish the post is the current owner/author of the post, and if the admin who approve/publish the post is not the post author, the post just get published without any metas updates

ok the solution was in the sequence of calling the action, and the save_post runs on updating the post anyway without applying any checks

so this can be a solution

function return_custom_price( $post ) {
global  $post;
$market = get_post_meta( $post->ID, 'market', true);
if($market == "" ){
    return;
}
$new_total = get_post_meta( $post->ID, '_total_egp', true);
$price = get_post_meta($post->ID, '_regular_price', true);
//$sale_price = get_post_meta($post->ID, '_sale_price', true);
$now_price = get_post_meta($post->ID, '_price', true);
$woo_usd_rate = get_post_meta( $post->ID, '_usd_rate', true);
$woo_price_usd = get_post_meta( $post->ID, '_price_usd', true);
$cog = $woo_price_usd * $woo_usd_rate;

update_post_meta($post->ID, '_regular_price', $new_total);
update_post_meta($post->ID, '_sale_price', '');
update_post_meta($post->ID, '_price', $new_total);
update_post_meta( $post->ID, '_wc_cog_cost', $cog );
}   
add_action('save_post', 'return_custom_price');