wpgenie icon

user role based bidding

wpgenie | PRO | 05/28/18 02:02:50 PM UTC | 0 ⭐ | 1480 👁️ | Never ⏰ | []
PHP |

540 B

|

None

|

0 👍

/

0 👎

/*
 WSA allows user role based bidding
 
Add to your functions.php
*/
add_filter( 'woocommerce_simple_auctions_before_place_bid_filter' , 'wsa_check_user_role' );
function wsa_check_user_role() {
    $current_user = wp_get_current_user();  
    if ( in_array ( 'subscriber', $current_user->roles ) ){
        wc_add_notice( esc_html__('You need user role that allows bidding. Your current role is "subscriber" which does not allow bidding.', 'wc_simple_auctions'), 'error' );
        return FALSE;
    } else {
        // user can place a bid
        return TRUE;
    }
}

Comments