Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. add_action( 'woocommerce_checkout_order_processed', 'gt_refuse_referrals_on_roles' );
  2. function gt_refuse_referrals_on_roles ( $order_id ) {
  3.  
  4.  
  5. $order = new WC_Order( $order_id );
  6.  
  7. $usr = (int)$order->user_id;
  8.  
  9. $current_user = get_userdata( $usr );
  10. $role_value = $current_user->roles;
  11.  
  12. write_log("ROLE=");
  13. write_log( $role_value );
  14.  
  15. $affiliate_id = '';
  16. $post_id = $order_id;
  17. $now = '';
  18. $description = '';
  19.  
  20. $data_array = array( $affiliate_id, $post_id, $now, $description );
  21. write_log( $data_array );
  22.  
  23. $affiliates_array = affiliates_get_affiliates( true, true);
  24. foreach ( $role_value as $role_element ) {
  25. if ( $role_element == 'administrator' || $role_element == 'shop_manager' ) {
  26. write_log("SUCCESS");
  27. apply_filters( 'affiliates_record_referral', false, $data_array );
  28. //$r = new Affiliates_Referral_WordPress();
  29. //$r->evaluate( $post_id, '', null, null, null, null, null, null, null, true );
  30. //$r->add_referrals( $affiliates_array, $post_id, '', '', '', '', '', '', '', '', true );
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement