Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save techjewel/d9bb25c5837a1da2717b25152f41257c to your computer and use it in GitHub Desktop.
Save techjewel/d9bb25c5837a1da2717b25152f41257c to your computer and use it in GitHub Desktop.
<?php
/*
* This snippet is assuming the user already logged in or the provided email address is available in users
* After the form submission the user will be added to the course.
*/
add_action( 'fluentform_submission_inserted', 'ff_register_user_to_learndash_course', 100, 3 );
function ff_register_user_to_learndash_course( $entryId, $formData, $form ) {
// Check if the form is the one we want
if ( $form->id != 123 ) { // Replace with your actual form ID
return;
}
if(empty($formData['email'])) { // assuming your form has an email field which is named 'email'
return;
}
$user = get_user_by('email', $formData['email']);
if(!$user) {
return;
}
$ldCourseId = 456; // Replace with your actual course ID
ld_update_course_access( $user->ID, $ldCourseId );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment