Programatically Enroll Student in a Course

imat
Hello, Is it possible to programmatically enroll students in a course?
Profile picture for user James Aparicio
James Aparicio

Hi imat,

Hi imat,

Ofc, http://www.drupalcontrib.org/api/drupal/contributions!og!og.module/function/og_group/7

Best regards

imat

Thank you James,

Thank you. I mean I need to programmatically enroll a student on a specific course and put a user expiration on it. Is there a method or API that I can use on Opigno? Thanks again!
Profile picture for user James Aparicio
James Aparicio

Hi imat,

Hi imat,

Yes, if you have the opigno user expiration app installed then the memberships will have a user expiration field.

That function registers a user to a group and returns the membership it created. Group type is node and gid is the nid of the course, the entity is the user.

After that just set the membership expiration date and save the membership.

Something like:

$membership=og_group(...);

$membership->expirationdatefield="...";

og_membership_save($membership);

http://www.drupalcontrib.org/api/drupal/contributions%21og%21og.module/function/og_membership_save/7

Best regards

imat

Thanks

Thank you!
imat

Thanks

Thank you!