wpgenie

Prevent vendor / admin / creator bidding on their own auctions

Dec 1st, 2020 (edited)
866
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3.     Prevent vendor / admin / creator bidding on their own auctions
  4.  
  5.     This code snippet should go to your child theme functions.php file.
  6.  
  7. */
  8. add_filter( 'woocommerce_simple_auctions_before_place_bid_filter' , 'wsa_check_creator', 1);
  9. function wsa_check_creator($product_data) {
  10.     $post1 = get_post( $product_data->id );
  11.     if ( get_current_user_id() == $post1->post_author ){
  12.         wc_add_notice( esc_html__( 'You cannot bid on your own auctions.', 'your_custom_translation').var_dump($post->post_author), 'error' );
  13.         return FALSE;
  14.     } else {        
  15.         // user can place a bid
  16.         return TRUE;
  17.     }
  18. }
RAW Paste Data