Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'woocommerce_checkout_order_processed', 'gt_refuse_referrals_on_roles' );
- function gt_refuse_referrals_on_roles ( $order_id ) {
- $order = new WC_Order( $order_id );
- $usr = (int)$order->user_id;
- $current_user = get_userdata( $usr );
- $role_value = $current_user->roles;
- write_log("ROLE=");
- write_log( $role_value );
- $affiliate_id = '';
- $post_id = $order_id;
- $now = '';
- $description = '';
- $data_array = array( $affiliate_id, $post_id, $now, $description );
- write_log( $data_array );
- $affiliates_array = affiliates_get_affiliates( true, true);
- foreach ( $role_value as $role_element ) {
- if ( $role_element == 'administrator' || $role_element == 'shop_manager' ) {
- write_log("SUCCESS");
- apply_filters( 'affiliates_record_referral', false, $data_array );
- //$r = new Affiliates_Referral_WordPress();
- //$r->evaluate( $post_id, '', null, null, null, null, null, null, null, true );
- //$r->add_referrals( $affiliates_array, $post_id, '', '', '', '', '', '', '', '', true );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement