wpgenie icon

Prevent vendor / admin / creator bidding on their own auctions

wpgenie | PRO | 05/11/21 08:57:12 AM UTC (Edited) | 0 ⭐ | 1902 👁️ | Never ⏰ | []
PHP |

610 B

|

None

|

0 👍

/

0 👎

/*
 
    Prevent vendor / admin / creator bidding on their own auctions
 
    This code snippet should go to your child theme functions.php file.
 
*/
add_filter( 'woocommerce_simple_auctions_before_place_bid_filter' , 'wsa_check_creator', 1);
function wsa_check_creator($product_data) {
    $post1 = get_post( $product_data->id );
    if ( get_current_user_id() == $post1->post_author ){
        wc_add_notice( esc_html__( 'You cannot bid on your own auctions.', 'your_custom_translation'), 'error' );
        return FALSE;
    } else {        
        // user can place a bid
        return TRUE;
    }
}

Comments