Created
October 17, 2022 08:53
-
-
Save goranefbl/ee8a69274cdc5eae163b492f4ee3fcdf to your computer and use it in GitHub Desktop.
user registration reward
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'user_register', 'generate_coupon', 10, 1 ); | |
| function generate_coupon( $user_id ) { | |
| if(isset($_COOKIE["gens_raf"])) { | |
| $referral_code = $_COOKIE["gens_raf"]; | |
| global $wpdb; | |
| $results = $wpdb->get_results($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key='gens_referral_id' AND meta_value = %s", $referral_code)); | |
| if(!empty($results)) { | |
| $user_id = (int)$results[0]->user_id; | |
| } | |
| // You got ID of user that referred friend, now create a coupon and assign it to him. Check WPGens_RAF_Coupons class. | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment