As a part of my custom plugin (based on woocommerce) development I have assigned authors to products and willing to hide the add to cart button for product authors, so that I can restrict authors from buying their own product.
For this I have tried the below code but i am not able to hide the add to cart button from authors.
add_action('after_setup_theme','user_filter_addtocart') ;
function user_filter_addtocart(){
$user_id = get_current_user_id();
$author_id = get_post_field('post_author', get_the_ID());
if(get_current_user_id() === $author_id){
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30, 3 );
}
}