Advertisement
wpgenie

user role based bidding

May 28th, 2018
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. /*
  2.  WSA allows user role based bidding
  3.  
  4. Add to your functions.php
  5. */
  6. add_filter( 'woocommerce_simple_auctions_before_place_bid_filter' , 'wsa_check_user_role' );
  7. function wsa_check_user_role() {
  8.     $current_user = wp_get_current_user(); 
  9.     if ( in_array ( 'subscriber', $current_user->roles ) ){
  10.         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' );
  11.         return FALSE;
  12.     } else {
  13.         // user can place a bid
  14.         return TRUE;
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement