Created
May 11, 2016 19:45
-
-
Save ejonasson/a621c676c6e07fdf350db3fe7edf2bbc to your computer and use it in GitHub Desktop.
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
| // Where $email = your user's email address | |
| // and $product_id = the ID number of the product you'd like to add them to | |
| $zippy = Zippy::instance(); | |
| $user_id = email_exists($email); | |
| if (!$user_id) { | |
| $student = $zippy->make('student'); | |
| $student->username = $$email; | |
| $student->email = $email; | |
| $student->password = wp_generate_password(); | |
| $student->role = 'subscriber'; | |
| $student->register(); | |
| } else { | |
| $student = $zippy->make('student', array($user_id)); | |
| $student->fetch(); | |
| } | |
| // Claim the order on either the old or new student account | |
| $zippy->access->claim($student->getId(), $product_id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment