Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'woocommerce_payment_complete', 'mycred_pro_give_points_to_all_woo', 10, 3 );
- function mycred_pro_give_points_to_all_woo( $order_id ) {
- // Make sure myCRED is installed
- if ( ! function_exists( 'mycred' ) ) return;
- global $wpdb;
- // Load myCRED
- $mycred = mycred();
- // Get all users that have a balance
- $all_users = $wpdb->get_col( $wpdb->prepare( "
- SELECT users.ID
- FROM {$wpdb->users} users
- INNER JOIN {$wpdb->usermeta} balance
- ON ( users.ID = balance.user_id )
- WHERE balance.meta_key = %s
- AND balance.meta_value != '';", $ctype ) );
- // Loop
- if ( $all_users ) {
- foreach ( $all_users as $user_id ) {
- // Make sure user is not excluded
- if ( $mycred->exclude_user( $user_id ) ) continue;
- // Award
- $mycred->add_creds(
- 'product_purchase',
- $user_id,
- 10,
- '%plural% for store purchase',
- $order_id,
- array( 'ref_type' => 'post' )
- );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement