title: How to check if a product is created by a user in woocommerce
body: <p>Good Day, i'm trying to check if a product is created by a user and if no, the add to cart button should be removed.</p>
  
  <p>I'm working on a store whereby a registered user can create product from frontend. I added this argument to create the product from frontend;</p>
  
  <pre><code>$post = array(
          'post_author' =&gt; $currentCOUser_ID // This Return the User's ID using wp_get_current_user()-&gt;ID
          'post_status' =&gt; "publish",
          'post_excerpt' =&gt; $pProduct_excerpt,
          'post_title' =&gt; $ProductTitle,
          'post_type' =&gt; "product",
      );
  
      //create product for product ID
      $product_id = wp_insert_post( $post, __('Cannot create product', 'izzycart-function-code') );
  </code></pre>
  
  <p>When product is created i only want the author and admin to be able to see the add to cart button on the product single page. I used the below code but didn't work;</p>
  
  <pre><code>function remove_product_content() {
      global $post;
      $current_user = wp_get_current_user();
      $product_author_id = $current_user-&gt;ID;
      $admin_role = in_array( 'administrator', (array) $current_user-&gt;roles );
  
  
      //check if is a product &amp; user is logged in and is either admin or the author
      //is a product and user is not logged in, remove add to cart
      //is a product and user is logged in and not either admin or product author, remove add to cart button
      if ( is_product() &amp;&amp; is_user_logged_in() &amp;&amp; (!$admin_role || $product_author_id != $post-&gt;post_author)  ) {
          remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
      }
  }
  add_action( 'wp', 'remove_product_content' );
  </code></pre>
  
  <p>when i run the above code, it completely hide the add to cart button from everyone. Not sure what i'm doing wrong. Thanks for your help.</p>