Skip to content

Instantly share code, notes, and snippets.

@ejonasson
Created May 11, 2016 19:45
Show Gist options
  • Select an option

  • Save ejonasson/a621c676c6e07fdf350db3fe7edf2bbc to your computer and use it in GitHub Desktop.

Select an option

Save ejonasson/a621c676c6e07fdf350db3fe7edf2bbc to your computer and use it in GitHub Desktop.
// 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